-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
cli.js
executable file
·41 lines (31 loc) · 829 Bytes
/
cli.js
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
#!/usr/bin/env node
var fs = require("fs");
var argv = require("minimist")(process.argv.slice(2));
var useYarn = require(".");
if (argv.v || argv.version) {
console.log(require("./package.json").version);
process.exit();
}
const npm_execpath_arg = argv._[0];
var message;
const fileArg = argv.f || argv.file;
const messageArg = argv.m || argv.message;
if (fileArg) {
message = fs.readFileSync(fileArg, "utf8");
} else if (messageArg) {
message = messageArg;
}
if (process.stdin.isTTY || npm_execpath_arg) {
useYarn({ message, npm_execpath: npm_execpath_arg });
} else {
process.stdin.on("readable", () => {
let buffer = "";
let chunk;
while ((chunk = process.stdin.read()) != null) {
buffer += chunk;
}
if (buffer) {
useYarn({ message, npm_execpath: buffer });
}
});
}