forked from sindresorhus/strip-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·29 lines (26 loc) · 684 Bytes
/
cli.js
File metadata and controls
executable file
·29 lines (26 loc) · 684 Bytes
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
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var getStdin = require('get-stdin');
var meow = require('meow');
var strip = require('./');
var cli = meow([
'Usage',
' $ strip-debug <input file> > <output file>',
' $ cat <input file> | strip-debug > <output file>',
'',
'Examples',
' $ strip-debug src/app.js > dist/app.js',
' $ cat src/app.js | strip-debug > dist/app.js'
]);
if (process.stdin.isTTY) {
if (!cli.input[0]) {
console.error('Input file required');
process.exit(1);
}
process.stdout.write(strip(fs.readFileSync(cli.input[0], 'utf8')).toString());
} else {
getStdin(function (data) {
process.stdout.write(strip(data).toString());
});
}