-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·113 lines (104 loc) · 2.1 KB
/
cli.js
File metadata and controls
executable file
·113 lines (104 loc) · 2.1 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env node
//-
//- Usage
//- lj [init|bench|build|help|test]
//-
//- global options
//- --debug Print parsed options
//-
//- Examples
//- lj b --out=ui/index.html ui/dev.html
//- lj r
//-
var fs = require("fs")
, path = require("path")
, cli = require("./index.js")
, opts = require("./opts.js").opts({
bench: {
samples: 10,
sampleTime: 500,
warmup: 2000
},
build_b: {
banner: "",
cat: true,
assets: "{h}.{ext}",
fetch: true,
jsmin: "",
min: "",
out: "",
readme: "",
ver: "",
worker: ""
},
init_i: {},
lint: {
jshint: "",
fix: false,
_: ["*.css", "*.json", "*.js"]
},
release_r: {
build: true,
commit: true,
global: "",
install: true,
lint: true,
rewrite: false,
setVersion: ["package.json#version"],
tag:true,
test: true,
update: true,
upstream: true
},
serve: {
port: 8080
},
static: {
base: "",
cat: true,
fetch: true,
min: true,
script: true,
out: "_site/",
},
"ui-test": {
port: 8091,
budget: 5000,
_: ["test/index.html"]
},
test_t: {
status: true,
tz: "",
up: false,
watch: false,
_: ["test/*.js"]
},
color: true,
debug: false,
help: false,
version: true
}, "package.json#litejs,.github/litejs.json")
, package = require("./package.json")
, userPackage = {}
try {
userPackage = require(path.resolve("package.json"))
} catch(e) {}
var ver = package.name + "@" + package.version + " on " + cli.engine + "@" + cli.engineVersion
, cmd = opts._cmd
, libFile = cmd && "./lib/" + cmd + ".js"
if (opts.tz) process.env.TZ = opts.tz
if (opts.version) console.error("#%s %s@%s with %s", (cmd ? " " + cmd : ""), userPackage.name, userPackage.version, ver)
if (opts.debug) console.error(opts)
if (opts._unknown[0] && cmd !== "test") {
console.error("\nError: Unknown option: " + opts._unknown)
usage()
process.exit(1)
} else if (libFile && !opts.help) {
require(libFile)(opts)
} else {
usage()
}
function usage() {
var helpFile = libFile ? path.resolve(module.filename, "." + libFile) : module.filename
console.log(fs.readFileSync(helpFile, "utf8").match(/^\/\/-.*/gm).join("\n").replace(/^.../gm, ""))
}