listpage_cli 0.0.188 → 0.0.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli.js
CHANGED
|
@@ -14,6 +14,16 @@ function printHelp() {
|
|
|
14
14
|
].join("\n");
|
|
15
15
|
console.log(h);
|
|
16
16
|
}
|
|
17
|
+
function printVersion() {
|
|
18
|
+
try {
|
|
19
|
+
const p = path_1.default.join(__dirname, "..", "package.json");
|
|
20
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(p, "utf8"));
|
|
21
|
+
console.log(pkg.version || "");
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
console.log("");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
17
27
|
function safePkgName(name) {
|
|
18
28
|
return name
|
|
19
29
|
.toLowerCase()
|
|
@@ -100,7 +110,8 @@ function copyDir(src, dest) {
|
|
|
100
110
|
ensureDir(dest);
|
|
101
111
|
for (const entry of fs_1.default.readdirSync(src)) {
|
|
102
112
|
const s = path_1.default.join(src, entry);
|
|
103
|
-
const
|
|
113
|
+
const outEntry = entry === "gitignore" ? ".gitignore" : entry;
|
|
114
|
+
const d = path_1.default.join(dest, outEntry);
|
|
104
115
|
const stat = fs_1.default.statSync(s);
|
|
105
116
|
if (stat.isDirectory())
|
|
106
117
|
copyDir(s, d);
|
|
@@ -184,7 +195,10 @@ function copyTemplateDir(srcDir, destDir, vars) {
|
|
|
184
195
|
files.forEach((src) => {
|
|
185
196
|
const rel = path_1.default.relative(srcDir, src);
|
|
186
197
|
const isTmpl = rel.endsWith(".tmpl");
|
|
187
|
-
|
|
198
|
+
let outRel = isTmpl ? rel.slice(0, -5) : rel;
|
|
199
|
+
if (path_1.default.basename(outRel) === "gitignore") {
|
|
200
|
+
outRel = path_1.default.join(path_1.default.dirname(outRel), ".gitignore");
|
|
201
|
+
}
|
|
188
202
|
const dest = path_1.default.join(destDir, outRel);
|
|
189
203
|
ensureDir(path_1.default.dirname(dest));
|
|
190
204
|
const buf = fs_1.default.readFileSync(src, "utf8");
|
|
@@ -201,7 +215,12 @@ function renderVars(str, vars) {
|
|
|
201
215
|
return out;
|
|
202
216
|
}
|
|
203
217
|
async function main() {
|
|
204
|
-
const
|
|
218
|
+
const args = process.argv.slice(2);
|
|
219
|
+
if (args.includes("--version") || args.includes("-V")) {
|
|
220
|
+
printVersion();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
const cmd = args[0];
|
|
205
224
|
if (cmd === "init")
|
|
206
225
|
return initCmd();
|
|
207
226
|
printHelp();
|
package/package.json
CHANGED