@kevin0181/memoc 1.0.4 → 1.0.5
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 +19 -7
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -209,15 +209,15 @@ function write(filePath, content) {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
function tplMemocCmdWrapper() {
|
|
212
|
-
return `@echo off\r\
|
|
212
|
+
return `@echo off\r\nnpm exec --yes --package "@kevin0181/memoc" -- memoc %*\r\n`;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
function tplMemocPs1Wrapper() {
|
|
216
|
-
return `
|
|
216
|
+
return `npm exec --yes --package '@kevin0181/memoc' -- memoc @args\nexit $LASTEXITCODE\n`;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
function tplMemocShWrapper() {
|
|
220
|
-
return `#!/bin/sh\nexec
|
|
220
|
+
return `#!/bin/sh\nexec npm exec --yes --package '@kevin0181/memoc' -- memoc "$@"\n`;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
function defaultUserBinDir() {
|
|
@@ -247,9 +247,9 @@ function ensurePathHelpers(dir, mark) {
|
|
|
247
247
|
|
|
248
248
|
for (const [fp, tpl, executable] of files) {
|
|
249
249
|
const rel = path.relative(dir, fp);
|
|
250
|
-
const added =
|
|
250
|
+
const added = writeIfChanged(fp, tpl());
|
|
251
251
|
if (executable) chmodExecutable(fp);
|
|
252
|
-
mark(added
|
|
252
|
+
mark(added, rel);
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -267,12 +267,24 @@ function writeLaunchers(binDir, mark, label) {
|
|
|
267
267
|
];
|
|
268
268
|
|
|
269
269
|
for (const [fp, tpl, executable] of files) {
|
|
270
|
-
const added =
|
|
270
|
+
const added = writeIfChanged(fp, tpl());
|
|
271
271
|
if (executable) chmodExecutable(fp);
|
|
272
|
-
mark(added
|
|
272
|
+
mark(added, `${label} ${path.basename(fp)}`);
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
+
function writeIfChanged(filePath, content) {
|
|
277
|
+
if (!fs.existsSync(filePath)) {
|
|
278
|
+
write(filePath, content);
|
|
279
|
+
return 'add';
|
|
280
|
+
}
|
|
281
|
+
try {
|
|
282
|
+
if (fs.readFileSync(filePath, 'utf8') === content) return 'skip';
|
|
283
|
+
} catch {}
|
|
284
|
+
write(filePath, content);
|
|
285
|
+
return 'update';
|
|
286
|
+
}
|
|
287
|
+
|
|
276
288
|
function ensurePathRegistration(dir, mark) {
|
|
277
289
|
ensureCurrentPathLauncher(mark);
|
|
278
290
|
const binDir = ensureUserLauncher(mark);
|