Skip to content

Commit d0dff60

Browse files
committed
Upgrade modules
1 parent 2395576 commit d0dff60

File tree

7 files changed

+42
-39
lines changed

7 files changed

+42
-39
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
node-version: ${{ matrix.node-version }}
2020
- run: git config --global user.name "Github Actions"
2121
- run: git config --global user.email "[email protected]"
22-
- run: npm install ts-dev-stack node-version-use depcheck -g --force
22+
- run: npm install ts-dev-stack node-version-use depcheck -g -f
2323
- run: depcheck
2424
- run: npm ci
2525
- run: npm run build

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"version": "tsds version"
4545
},
4646
"dependencies": {
47-
"cross-spawn-cb": "^2.1.0",
47+
"cross-spawn-cb": "^2.1.2",
4848
"exit": "^0.1.2",
4949
"getopts-compat": "^2.2.5",
5050
"queue-cb": "^1.4.10",

src/cli.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ export default (argv, name) => {
3131
options.stdio = 'inherit';
3232
disDat(args, options, (err, results) => {
3333
if (err && err.message.indexOf('ExperimentalWarning') >= 0) err = null;
34-
if (err) console.log(err.message);
35-
34+
if (err) {
35+
results = err.results;
36+
console.log(err.message);
37+
}
3638
const errors = results.filter((result) => !!result.error);
39+
3740
if (!options.silent) {
3841
console.log('\n======================');
3942
console.log(`${name} "${args.join('" "')}" ${errors.length ? 'failed' : 'succeeded'}`);
4043
results.forEach((res) => console.log(`${res.error ? figures.cross : figures.tick} ${[res.command].concat(res.args).join(' ')}${res.error ? ` Error: ${res.error.message}` : ''}`));
4144
}
42-
exit(errors.length ? -1 : 0);
45+
exit(err || errors.length ? -1 : 0);
4346
});
4447
};

src/worker.js

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,36 @@ module.exports = function run(commands, options, callback) {
99
let results = [];
1010
const queue = new Queue(options.concurrency || Infinity);
1111

12-
for (let index = 0; index < commands.length; index++) {
13-
((index) => {
14-
queue.defer((cb) => {
15-
const command = commands[index];
16-
const match = commands[index].match(bracketsRegEx);
17-
const argv = match ? parse(match[1]) : parse(command);
18-
const args = argv.slice(1);
12+
commands.forEach((_command, index) => {
13+
queue.defer((cb) => {
14+
const command = commands[index];
15+
const match = commands[index].match(bracketsRegEx);
16+
const argv = match ? parse(match[1]) : parse(command);
17+
const args = argv.slice(1);
1918

20-
!options.header || options.header(command);
21-
spawn(argv[0], args, spawnOptions, (err, result) => {
22-
if (err && err.message.indexOf('ExperimentalWarning') >= 0) {
23-
res = err;
24-
err = null;
25-
}
19+
!options.header || options.header(command);
20+
spawn(argv[0], args, spawnOptions, (err, result) => {
21+
if (err && err.message.indexOf('ExperimentalWarning') >= 0) {
22+
res = err;
23+
err = null;
24+
}
2625

27-
// suppress error
28-
if (err && match) {
29-
result = err;
30-
err = null;
31-
}
26+
// suppress error
27+
if (err && match) {
28+
result = err;
29+
err = null;
30+
}
3231

33-
results.push({ index, command: argv[0], args, error: err, result });
34-
if (err && options.concurrency === 1) return cb(err); // break early
35-
cb();
36-
});
32+
results.push({ index, command: argv[0], args, error: err, result });
33+
if (err && options.concurrency === 1) return cb(err); // break early
34+
cb();
3735
});
38-
})(index);
39-
}
36+
});
37+
});
4038

41-
queue.await(() => {
39+
queue.await((err) => {
4240
results = results.sort((a, b) => a.index - b.index);
43-
callback(null, results);
41+
if (err) err.results = results;
42+
err ? callback(err) : callback(null, results);
4443
});
4544
};

test/spec/cli.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('cli', () => {
3535
assert.ok(err.status !== 0);
3636
const lines = cr(err.stdout).split('\n');
3737
const versions = lines.slice(-3, -1);
38-
assert.equal(versions.length, 1);
38+
assert.equal(versions.length, 2);
3939
assert.equal(versions[0], 'hello');
4040
done();
4141
});

test/spec/library.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ describe('library', () => {
3636
assert.ok(isVersion(cr(results[1].result.stdout).split('\n').slice(-2, -1)[0], 'v'));
3737
});
3838
it('handles errors - stops in dtd', (done) => {
39-
disDat(['echo "hello"', 'this is an error', 'node --version'], { concurrency: 1, encoding: 'utf8' }, (err, results) => {
40-
if (err) return done(err);
39+
disDat(['echo "hello"', 'this is an error', 'node --version'], { concurrency: 1, encoding: 'utf8' }, (err) => {
40+
assert.ok(!!err);
41+
const results = err.results;
4142
assert.ok(results.length === 2);
4243
assert.equal(cr(results[0].result.stdout).split('\n').slice(-2, -1)[0], 'hello');
4344
assert.ok(results[1].error);

0 commit comments

Comments
 (0)