Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chokidar-cli

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chokidar-cli - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

26

index.js

@@ -69,3 +69,4 @@ #!/usr/bin/env node

'Needs to be surrounded with quotes to prevent shell globbing. ' +
'The whole relative or absolute path is tested, not just filename'
'The whole relative or absolute path is tested, not just filename. ' +
'Supports glob patters or regexes using format: /yourmatch/i'
})

@@ -156,2 +157,5 @@ .option('initial', {

function createChokidarOpts(opts) {
// Transform e.g. regex ignores to real regex objects
opts.ignore = _resolveIgnoreOpt(opts.ignore);
var chokidarOpts = {

@@ -169,2 +173,22 @@ followSymlinks: opts.followSymlinks,

// Takes string or array of strings
function _resolveIgnoreOpt(ignoreOpt) {
if (!ignoreOpt) {
return ignoreOpt;
}
var ignores = !_.isArray(ignoreOpt) ? [ignoreOpt] : ignoreOpt;
return _.map(ignores, function(ignore) {
var isRegex = ignore[0] === '/' && ignore[ignore.length - 1] === '/';
if (isRegex) {
// Convert user input to regex object
var match = ignore.match(new RegExp('^/(.*)/(.*?)$'));
return new RegExp(match[1], match[2]);
}
return ignore;
});
}
function run(cmd) {

@@ -171,0 +195,0 @@ return utils.run(cmd)

2

package.json
{
"name": "chokidar-cli",
"description": "Ultra-fast cross-platform command line utility to watch file system changes.",
"version": "0.2.1",
"version": "0.3.0",
"keywords": [

@@ -6,0 +6,0 @@ "fs",

@@ -88,29 +88,29 @@ # Chokidar CLI

references and bubbling events through the links path
[boolean] [default: false]
-i, --ignore Pattern for files which should be ignored. Needs to
be surrounded with quotes to prevent shell globbing.
The whole relative or absolute path is tested, not
just filename
[boolean] [default: false]
-i, --ignore Pattern for files which should be ignored. Needs to be
surrounded with quotes to prevent shell globbing. The
whole relative or absolute path is tested, not just
filename. Supports glob patters or regexes using
format: /yourmatch/i
--initial When set, command is initially run once
[boolean] [default: false]
-p, --polling Whether to use fs.watchFile(backed by polling)
instead of fs.watch. This might lead to high CPU
utilization. It is typically necessary to set this to
true to successfully watch files over a network, and
it may be necessary to successfully watch files in
other non-standard situations
[boolean] [default: false]
--poll-interval Interval of file system polling. Effective when
--polling is set [default: 100]
[boolean] [default: false]
-p, --polling Whether to use fs.watchFile(backed by polling) instead
of fs.watch. This might lead to high CPU utilization.
It is typically necessary to set this to true to
successfully watch files over a network, and it may be
necessary to successfully watch files in other non-
standard situations [boolean] [default: false]
--poll-interval Interval of file system polling. Effective when --
polling is set [default: 100]
--poll-interval-binary Interval of file system polling for binary files.
Effective when --polling is set [default: 300]
--verbose When set, output is more verbose and human readable.
[boolean] [default: false]
-h, --help Show help
-v, --version Show version number
[boolean] [default: false]
-h, --help Show help [boolean]
-v, --version Show version number [boolean]
Examples:
chokidar "**/*.js" -c "npm run build-js" build when any .js file changes
chokidar "**/*.js" "**/*.less" output changes of .js and .less
files
chokidar "**/*.js" -c "npm run build-js" build when any .js file changes
chokidar "**/*.js" "**/*.less" output changes of .js and .less
files
```

@@ -117,0 +117,0 @@

@@ -62,5 +62,7 @@ // Test basic usage of cli. Contains confusing setTimeouts

// Use a file to detect that trigger command is actually run
var touch = 'touch ' + CHANGE_FILE
var touch = 'touch ' + CHANGE_FILE;
// No quotes needed in glob pattern because node process spawn
// does no globbing
// TODO: touch command does not always create file before assertion
run('node ../index.js "dir/**/*.less" -c "' + touch + '"', {

@@ -67,0 +69,0 @@ pipe: DEBUG_TESTS,

@@ -19,22 +19,28 @@ var childProcess = require('child_process');

var child;
var parts = shellQuote.parse(cmd);
try {
child = childProcess.spawn(_.head(parts), _.tail(parts), {
cwd: opts.cwd,
stdio: opts.pipe ? "inherit" : null
});
} catch (e) {
return Promise.reject(e);
}
opts.callback(child);
return new Promise(function(resolve, reject) {
var child;
var parts = shellQuote.parse(cmd);
try {
child = childProcess.spawn(_.head(parts), _.tail(parts), {
cwd: opts.cwd,
stdio: opts.pipe ? 'inherit' : null
});
} catch (e) {
return Promise.reject(e);
}
return new Promise(function(resolve, reject) {
child.on('error', function(err) {
opts.callback(child);
function errorHandler(err) {
child.removeListener('close', closeHandler);
reject(err);
});
}
child.on('close', function(exitCode) {
function closeHandler(exitCode) {
child.removeListener('error', errorHandler);
resolve(exitCode);
});
}
child.once('error', errorHandler);
child.once('close', closeHandler);
});

@@ -41,0 +47,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc