Skip to content

Commit

Permalink
Deps, dates, CI, naturalise
Browse files Browse the repository at this point in the history
Remove exports, keeping exports default, to fix CJS build
  • Loading branch information
75lb committed Dec 6, 2024
1 parent 9acdc2c commit 5d317f4
Show file tree
Hide file tree
Showing 12 changed files with 176 additions and 2,927 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,32 @@ name: Node.js CI

on:
push:
branches: [ master ]
branches: [ master, next ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [14, 16, 18, 20, 22]
os: [ubuntu-latest, windows-latest]
node-version: [12, 14, 16, 18, 20, 22, 23]

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: sudo ./scripts/install-ubuntu.sh
- run: npm install
- run: npm i @75lb/nature
- run: npm run test:ci
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013-24 Lloyd Brookes <75pound@gmail.com>
Copyright (c) 2013-25 Lloyd Brookes <opensource@75lb.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ HANDBRAKECLI_PATH="./example/HandbrakeCLI"

* * *

&copy; 2013-24 Lloyd Brookes &lt;75pound@gmail.com&gt;.
&copy; 2013-25 Lloyd Brookes &lt;opensource@75lb.com&gt;.

Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ If `.cancel()` was called, this event is emitted once the underlying HandbrakeCL

* * *

&copy; 2013-24 Lloyd Brookes &lt;75pound@gmail.com&gt;.
&copy; 2013-25 Lloyd Brookes &lt;opensource@75lb.com&gt;.

Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

Expand Down
2 changes: 1 addition & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
import ansi from 'ansi-escape-sequences'
import commandLineArgs from 'command-line-args'
import * as hbjs from 'handbrake-js'
import hbjs from 'handbrake-js'
import cliOptions from '../lib/cli-options.js'
import util from 'util'

Expand Down
84 changes: 7 additions & 77 deletions dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var events = require('events');
var path = require('path');
var url = require('url');
var currentModulePaths = require('current-module-paths');
var toSpawnArgs = require('object-to-spawn-args');
var childProcess = require('child_process');
var util = require('util');

var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
function getModulePaths (fileURL) {
const __filename = url.fileURLToPath(fileURL);
const __dirname = path.dirname(__filename);
return { __filename, __dirname }
}

const { __dirname: __dirname$1 } = getModulePaths((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
const { __dirname: __dirname$1 } = currentModulePaths((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));

/* path to the HandbrakeCLI executable downloaded by the install script */
let HandbrakeCLIPath = null;
Expand Down Expand Up @@ -95,66 +88,6 @@ const muxing = {
}
};

function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}

/**
* @module object-to-spawn-args
*/

/**
* @param {object} - an object specifying the command-line options to set
* @param [options] {object}
* @param [options.quote] {boolean} - enquote the option values
* @param [options.optionEqualsValue] {boolean} - use `--option=value` notation
*/
function toSpawnArgs (object, options) {
options = Object.assign({
optionEqualsValueList: [],
optionEqualsValueExclusions: [],
}, options);
const output = [];

for (const prop in object) {
const value = object[prop];
if (value !== undefined) {
const dash = prop.length === 1 ? '-' : '--';
if ((options.optionEqualsValue && !options.optionEqualsValueExclusions.includes(prop)) || options.optionEqualsValueList.includes(prop)) {
if (value === true) {
output.push(dash + prop);
} else {
if (Array.isArray(value)) {
output.push(dash + prop + '=' + quote(value.join(','), options.quote));
} else {
output.push(dash + prop + '=' + quote(value, options.quote));
}
}
} else {
output.push(dash + prop);
if (value !== true) {
if (Array.isArray(value)) {
value.forEach(function (item) {
output.push(quote(item, options.quote));
});
} else {
output.push(quote(value, options.quote));
}
}
}
}
}
return output
}

function quote (value, toQuote) {
return toQuote ? '"' + value + '"' : value
}

var objectToSpawnArgs = toSpawnArgs;

var toSpawnArgs$1 = /*@__PURE__*/getDefaultExportFromCjs(objectToSpawnArgs);

/**
* @class
* @classdesc A handle on the HandbrakeCLI process. Emits events you can monitor to track progress. An instance of this class is returned by {@link module:handbrake-js.spawn}.
Expand Down Expand Up @@ -225,7 +158,7 @@ class Handbrake extends events.EventEmitter {
const optionsCopy = Object.assign({}, this.options);
/* All options except HandbrakeCLIPath should be passed into the Handbrake command */
delete optionsCopy.HandbrakeCLIPath;
const spawnArgs = toSpawnArgs$1(optionsCopy, {
const spawnArgs = toSpawnArgs(optionsCopy, {
optionEqualsValue: true,
optionEqualsValueExclusions: ['preset-import-file', 'preset-import-gui', 'subtitle-burned']
});
Expand Down Expand Up @@ -642,7 +575,7 @@ function exec (options = {}, done) {
const cmd = util.format(
'"%s" %s',
handbrakePath,
toSpawnArgs$1(optionsCopy, { quote: true }).join(' ')
toSpawnArgs(optionsCopy, { quote: true }).join(' ')
);
childProcess.exec(cmd, done);
}
Expand Down Expand Up @@ -677,10 +610,7 @@ async function run (options) {
});
})
}

var index = { cliOptions, spawn, exec, run };

exports.cliOptions = cliOptions;
exports.default = index;
exports.exec = exec;
exports.run = run;
exports.spawn = spawn;
module.exports = index;
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,4 @@ async function run (options) {
})
}

export { cliOptions, spawn, exec, run }
export default { cliOptions, spawn, exec, run }
Loading

0 comments on commit 5d317f4

Please sign in to comment.