mirror of
https://github.com/cachix/install-nix-action.git
synced 2025-06-08 18:04:29 +00:00
v6
This commit is contained in:
parent
cd5893b2c6
commit
70742d22d9
6774 changed files with 1602535 additions and 1 deletions
76
node_modules/sane/src/cli.js
generated
vendored
Executable file
76
node_modules/sane/src/cli.js
generated
vendored
Executable file
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
const sane = require('../');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const execshell = require('exec-sh');
|
||||
|
||||
if (argv._.length === 0) {
|
||||
const msg =
|
||||
'Usage: sane <command> [...directory] [--glob=<filePattern>] ' +
|
||||
'[--ignored=<filePattern>] [--poll] [--watchman] [--watchman-path=<watchmanBinaryPath>] [--dot] ' +
|
||||
'[--wait=<seconds>] [--only-changes] [--quiet]';
|
||||
console.error(msg);
|
||||
process.exit();
|
||||
}
|
||||
|
||||
const opts = {};
|
||||
const command = argv._[0];
|
||||
const dir = argv._[1] || process.cwd();
|
||||
const waitTime = Number(argv.wait || argv.w);
|
||||
const dot = argv.dot || argv.d;
|
||||
const glob = argv.glob || argv.g;
|
||||
const ignored = argv.ignored || argv.i;
|
||||
const poll = argv.poll || argv.p;
|
||||
const watchman = argv.watchman || argv.w;
|
||||
const watchmanPath = argv['watchman-path'];
|
||||
const onlyChanges = argv['only-changes'] | argv.o;
|
||||
const quiet = argv.quiet | argv.q;
|
||||
|
||||
if (dot) {
|
||||
opts.dot = true;
|
||||
}
|
||||
if (glob) {
|
||||
opts.glob = glob;
|
||||
}
|
||||
if (ignored) {
|
||||
opts.ignored = ignored;
|
||||
}
|
||||
if (poll) {
|
||||
opts.poll = true;
|
||||
}
|
||||
if (watchman) {
|
||||
opts.watchman = true;
|
||||
}
|
||||
if (watchmanPath) {
|
||||
opts.watchmanPath = watchmanPath;
|
||||
}
|
||||
|
||||
let wait = false;
|
||||
const watcher = sane(dir, opts);
|
||||
|
||||
watcher.on('ready', function() {
|
||||
if (!quiet) {
|
||||
console.log('Watching: ', dir + '/' + (opts.glob || ''));
|
||||
}
|
||||
if (!onlyChanges) {
|
||||
execshell(command);
|
||||
}
|
||||
});
|
||||
|
||||
watcher.on('change', function(filepath) {
|
||||
if (wait) {
|
||||
return;
|
||||
}
|
||||
if (!quiet) {
|
||||
console.log('Change detected in:', filepath);
|
||||
}
|
||||
execshell(command);
|
||||
|
||||
if (waitTime > 0) {
|
||||
wait = true;
|
||||
setTimeout(function() {
|
||||
wait = false;
|
||||
}, waitTime * 1000);
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue