Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update chokidar #464

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/lib/copyAndWatch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import chokidar from 'chokidar';
import fs from 'fs';
import path from 'path';
import { globSync } from 'glob';

const debug = console.log; //() => {};
const removeLeadingSlash = (s) => s.replace(/^\//, '');
Expand All @@ -20,7 +21,7 @@ const removeLeadingSlash = (s) => s.replace(/^\//, '');
*/
export function copyAndWatch(paths, { watch } = { watch: true }) {
for (const { src, srcPrefix, dst } of paths) {
const watcher = chokidar.watch(src, {
const watcher = chokidar.watch(globSync(src), {
ignored: /(^|[\/\\])\../, // ignore dot files
persistent: watch,
});
Expand Down
21 changes: 18 additions & 3 deletions build/tools/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,32 @@ import { mkdirSync } from 'fs';

mkdirSync('out', { recursive: true });

spawn('npm', ['run', 'watch'], {
const spawns = new Set();

function spawnAndCheck(cmd, args, options) {
const s = spawn(cmd, args, options);
spawns.add(s);
s.on('close', (code) => {
spawns.delete(s);
if (code !== 0) {
console.error(cmd, 'exited with code:', code);
[...spawns].forEach((s) => s.kill());
process.exit(code);
}
});
}

spawnAndCheck('npm', ['run', 'watch'], {
shell: true,
stdio: 'inherit',
});

spawn('node', ['build/tools/copy.js', '1'], {
spawnAndCheck('node', ['build/tools/copy.js', '1'], {
shell: true,
stdio: 'inherit',
});

spawn('npm', ['run', 'server'], {
spawnAndCheck('npm', ['run', 'server'], {
shell: true,
stdio: 'inherit',
});
159 changes: 58 additions & 101 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@
"@types/stats.js": "^0.17.3",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@webgpu/types": "^0.1.49",
"chokidar": "^3.6.0",
"chokidar": "^4.0.1",
"eslint": "^8.57.1",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-html": "^8.1.2",
"eslint-plugin-prettier": "^4.2.1",
"glob": "^10.4.5",
"glob": "^11.0.0",
"prettier": "^2.8.8",
"rollup": "^4.24.0",
"rollup-plugin-copy": "^3.5.0",
Expand Down
6 changes: 6 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import typescript from '@rollup/plugin-typescript';
import commonjs from '@rollup/plugin-commonjs';
import { readDirSyncRecursive } from './build/lib/readdir.js';

const nodeVersion = parseInt(process.version.substring(1));
if (isNaN(nodeVersion) || nodeVersion < 20) {
console.error('need node >= v20');
process.exit(1);
}

const outPath = 'out';

function wgslPlugin() {
Expand Down
1 change: 1 addition & 0 deletions sample/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function quitIfWebGPUNotAvailable(
if (!device) {
quitIfAdapterNotAvailable(adapter);
fail('Unable to get a device for an unknown reason');
return;
kainino0x marked this conversation as resolved.
Show resolved Hide resolved
}

device.lost.then((reason) => {
Expand Down
Loading