forked from davidmfoley/node-trucker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli
More file actions
executable file
·49 lines (43 loc) · 1.53 KB
/
Copy pathcli
File metadata and controls
executable file
·49 lines (43 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/env node
var optimist = require('optimist');
var trucker = require('./index');
var options = optimist
.usage("Move CommonJS source files or directories without breaking your app.\nFixes requires in javascript and coffeescript files.\n$0 source [additional sources...] destination [flags]")
.boolean('h')
.alias('h', 'help')
.describe('h', 'Show help')
.boolean('i')
.alias('i', 'info')
.describe('i', 'Print dependency information for a file or path')
.boolean('u')
.alias('u', 'unused')
.describe('u', 'Find files that are not required from any other files')
.boolean('m')
.alias('m', 'move')
.describe('m', 'Move one or more source files while fixing up any changed require paths')
.boolean('n')
.alias('n', 'dry-run')
.describe('n', 'Print out changes to be made but don\'t change anything (try this first!)')
.string('s')
.alias('s', 'scope')
.describe('s', 'Set top "scope" directory for scanning for dependencies (default: pwd)')
.string('q')
.alias('q', 'quiet')
.describe('q', 'Suppress output')
.string('e')
.alias('e', 'exclude')
.describe('e', 'Add file glob pattern to exclude (repeatable)');
var argv = options.argv,
fileCount = argv._length,
requiredFileCount = argv.i ? 1 : 2;
if (! (argv.h || argv.i || argv.m || argv.n || argv.u)) {
}
if (argv.exclude && (typeof argv.exclude === 'string')) {
argv.e = argv.exclude = [argv.exclude]
}
if (argv.h || fileCount < requiredFileCount) {
options.showHelp();
process.exit();
}
var result = trucker(argv);
process.exit(result);