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

Added --ignore option to CLI #51

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ The `up` command accepts the following options:
- Whether to watch for changes.
- Watches the working directory for changes.

- `-i`/`--ignore` `<paths>`

- When using `--watch`, define paths to ignore (comma separated)
- `.git,node_modules` are ignored by default and are added to your ignored paths
- eg: `--ignore public,vendor`

- `-r`/`--require` `<mod>`

- Specifies a module to require from each worker.
Expand Down
7 changes: 6 additions & 1 deletion bin/up
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ program
.option('-T, --title <title>', 'Process title.', 'up')
.option('-f, --pidfile <pidfile>', 'Write port to pidfile')
.option('-w, --watch', 'Watch the module directory for changes.')
.option('-i, --ignore <paths>', 'Ignore files when watching for changes.')
.option('-r, --require <file>', 'Module to require from each worker.')
.option('-n, --number <workers>', 'Number of workers to spawn.'
, 'development' == process.env.NODE_ENV ? 1 : cpus)
Expand Down Expand Up @@ -226,7 +227,11 @@ if (undefined != program.watch) {
* Ignored directories.
*/

var ignore = ['node_modules', '.git'];
if (undefined != program.ignore) {
var ignore = ['node_modules', '.git'].concat(program.ignore.split(","));
} else {
var ignore = ['node_modules', '.git'];
}

/**
* Ignored files.
Expand Down
13 changes: 12 additions & 1 deletion lib/up.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Module dependencies.
*/
Expand Down Expand Up @@ -257,6 +256,18 @@ UpServer.prototype.defaultWS = function (req, res, next) {
if(this.workers.length && matcher && matcher.length > 2) {
// transport = matcher[1], sid = matcher[2]
var sid = matcher[2];

if(typeof(sid) !== 'number') {
var glyphs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var result = 0;

sid = sid.split('');
for(var index = sid.length - 1; index >= 0; index--) {
result = (result * 64) + glyphs.indexOf(sid[index]);
}
sid = result;
}

var workerIndex = sid % this.workers.length;
next(this.workers[workerIndex].port);
} else if (this.workers.length) {
Expand Down