Skip to content

Commit d1a7c23

Browse files
committed
Update watchy/commander, 4.9.0
1 parent 7a564e6 commit d1a7c23

File tree

5 files changed

+22
-27
lines changed

5 files changed

+22
-27
lines changed

bin/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh
22

3-
exec node_modules/.bin/kiss-test 'src/**/*.test.js'
3+
exec node --test

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cogs",
3-
"version": "4.8.12",
3+
"version": "4.9.0",
44
"type": "module",
55
"author": "Casey Foster <c@sey.me>",
66
"description": "The fast file transform pipeline.",
@@ -19,11 +19,8 @@
1919
},
2020
"dependencies": {
2121
"chalk": "5",
22-
"commander": "13",
22+
"commander": "14",
2323
"underscore": "1",
24-
"watchy": "0.10"
25-
},
26-
"devDependencies": {
27-
"kiss-test": "0.2"
24+
"watchy": "0.11"
2825
}
2926
}

src/cli.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import fs from 'fs';
44
import npath from 'path';
5-
import url from 'url';
65

76
import chalk from 'chalk';
87
import { program } from 'commander';
@@ -11,9 +10,11 @@ import _ from 'underscore';
1110
import formatSize from './format-size.js';
1211
import run from './run.js';
1312

13+
const { URL } = globalThis;
14+
1415
['SIGTERM', 'SIGINT'].forEach(sig => process.once(sig, () => process.exit()));
1516

16-
const { path: thisPath } = url.parse(import.meta.url);
17+
const { pathname: thisPath } = new URL(import.meta.url);
1718
const packagePath = `${npath.dirname(thisPath)}/../package.json`;
1819
const { version } = JSON.parse(fs.readFileSync(packagePath));
1920

@@ -32,10 +33,6 @@ program
3233
'rebuild if [path] changes, can be specified multiple times',
3334
(path, paths = []) => [].concat(paths, path)
3435
)
35-
.option(
36-
'-p, --use-polling',
37-
'use stat polling instead of fsevents when watching'
38-
)
3936
.option('-s, --silent', 'do not output build information, only errors')
4037
.parse(process.argv);
4138

src/cli.test.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { strict as assert } from 'assert';
2-
import { spawn } from 'child_process';
3-
import { promises as fs } from 'fs';
1+
import { strict as assert } from 'node:assert';
2+
import { spawn } from 'node:child_process';
3+
import { promises as fs } from 'node:fs';
4+
import { test } from 'node:test';
45

56
const deleteBuilt = async () => {
67
try {
@@ -14,7 +15,8 @@ const deleteBuilt = async () => {
1415
}
1516
};
1617

17-
export default async done => {
18+
test('basic build', async () => {
19+
const { promise, resolve, reject } = Promise.withResolvers();
1820
await deleteBuilt();
1921
const ps = spawn('node', ['src/cli.js', '-c', 'test-fixtures/config.js'], {
2022
stdio: ['inherit', 'inherit', 'inherit']
@@ -43,9 +45,11 @@ export default async done => {
4345
'# start\nF\n# end\n'
4446
);
4547
await deleteBuilt();
46-
done();
48+
resolve();
4749
} catch (er) {
48-
done(er);
50+
reject(er);
4951
}
5052
});
51-
};
53+
54+
return promise;
55+
});

src/run.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import npath from 'path';
22

33
import _ from 'underscore';
4-
import watchy from 'watchy';
4+
import { watch } from 'watchy';
55

66
import buildConfig from './build-config.js';
77
import bustCache from './bust-cache.js';
@@ -14,7 +14,6 @@ export default async ({
1414
onEnd = _.noop,
1515
onResult = _.noop,
1616
onStart = _.noop,
17-
usePolling = false,
1817
watchPaths = []
1918
}) => {
2019
let building = false;
@@ -72,14 +71,12 @@ export default async ({
7271
timeoutId = setTimeout(tryBuild, debounce * 1000);
7372
};
7473

75-
const watcher = await watchy({
76-
onError,
74+
const closeWatcher = watch({
7775
onChange: handleChangedPath,
78-
patterns: [].concat(configPath, watchPaths),
79-
usePolling
76+
patterns: [].concat(configPath, watchPaths)
8077
});
8178

8279
await tryBuild();
8380

84-
return watcher;
81+
return closeWatcher;
8582
};

0 commit comments

Comments
 (0)