@jsenv/cli 0.2.0 → 0.2.2
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/jsenv_cli.js +13 -7
- package/package.json +1 -1
package/jsenv_cli.js
CHANGED
|
@@ -285,8 +285,8 @@ write_files: {
|
|
|
285
285
|
const fromStat = statSync(fromUrl);
|
|
286
286
|
if (fromStat.isDirectory()) {
|
|
287
287
|
if (directoryEntryName === "src" || directoryEntryName === "tests") {
|
|
288
|
-
if (existsSync(toUrl)) {
|
|
289
|
-
// copy src and tests if they don't exists
|
|
288
|
+
if (existsSync(toUrl) && readdirSync(toUrl).length > 0) {
|
|
289
|
+
// copy src and tests if they don't exists or are empty
|
|
290
290
|
continue;
|
|
291
291
|
}
|
|
292
292
|
if (isWebAndHaveRootHtmlFile) {
|
|
@@ -301,7 +301,7 @@ write_files: {
|
|
|
301
301
|
);
|
|
302
302
|
continue;
|
|
303
303
|
}
|
|
304
|
-
let templateFileContent = String(readFileSync(
|
|
304
|
+
let templateFileContent = String(readFileSync(fromUrl));
|
|
305
305
|
if (isWebAndHaveRootHtmlFile) {
|
|
306
306
|
if (directoryEntryName === ".eslintrc.cjs") {
|
|
307
307
|
templateFileContent = templateFileContent.replaceAll(
|
|
@@ -325,11 +325,17 @@ write_files: {
|
|
|
325
325
|
label: "npm start",
|
|
326
326
|
run: () => runWithChildProcess("npm start"),
|
|
327
327
|
});
|
|
328
|
+
const packageTemplateObject = JSON.parse(templateFileContent);
|
|
329
|
+
packageTemplateObject.name = urlToFilename(directoryUrl);
|
|
330
|
+
const packageString = JSON.stringify(
|
|
331
|
+
packageTemplateObject,
|
|
332
|
+
null,
|
|
333
|
+
" ",
|
|
334
|
+
);
|
|
335
|
+
writeFileSync(toUrl, packageString);
|
|
336
|
+
} else {
|
|
337
|
+
writeFileSync(toUrl, templateFileContent);
|
|
328
338
|
}
|
|
329
|
-
const packageTemplateObject = JSON.parse(templateFileContent);
|
|
330
|
-
packageTemplateObject.name = urlToFilename(directoryUrl);
|
|
331
|
-
const packageString = JSON.stringify(packageTemplateObject, null, " ");
|
|
332
|
-
writeFileSync(toUrl, packageString);
|
|
333
339
|
continue;
|
|
334
340
|
}
|
|
335
341
|
const relativeUrl = urlToRelativeUrl(fromUrl, templateSourceDirectoryUrl);
|