@jsenv/cli 0.2.1 → 0.2.3
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 +16 -9
- package/package.json +1 -1
package/jsenv_cli.js
CHANGED
|
@@ -264,9 +264,6 @@ write_files: {
|
|
|
264
264
|
return false;
|
|
265
265
|
})();
|
|
266
266
|
const copyDirectoryContent = (fromDirectoryUrl, toDirectoryUrl) => {
|
|
267
|
-
if (!existsSync(toDirectoryUrl)) {
|
|
268
|
-
mkdirSync(toDirectoryUrl, { recursive: true });
|
|
269
|
-
}
|
|
270
267
|
const directoryEntryNameArray = readdirSync(fromDirectoryUrl);
|
|
271
268
|
for (const directoryEntryName of directoryEntryNameArray) {
|
|
272
269
|
if (
|
|
@@ -285,8 +282,8 @@ write_files: {
|
|
|
285
282
|
const fromStat = statSync(fromUrl);
|
|
286
283
|
if (fromStat.isDirectory()) {
|
|
287
284
|
if (directoryEntryName === "src" || directoryEntryName === "tests") {
|
|
288
|
-
if (existsSync(toUrl)) {
|
|
289
|
-
// copy src and tests if they don't exists
|
|
285
|
+
if (existsSync(toUrl) && readdirSync(toUrl).length > 0) {
|
|
286
|
+
// copy src and tests if they don't exists or are empty
|
|
290
287
|
continue;
|
|
291
288
|
}
|
|
292
289
|
if (isWebAndHaveRootHtmlFile) {
|
|
@@ -316,6 +313,10 @@ write_files: {
|
|
|
316
313
|
}
|
|
317
314
|
}
|
|
318
315
|
if (!existsSync(toUrl)) {
|
|
316
|
+
const parentDirectoryUrl = new URL("./", toUrl);
|
|
317
|
+
if (!existsSync(parentDirectoryUrl)) {
|
|
318
|
+
mkdirSync(parentDirectoryUrl, { recursive: true });
|
|
319
|
+
}
|
|
319
320
|
if (directoryEntryName === "package.json") {
|
|
320
321
|
commands.push({
|
|
321
322
|
label: "npm install",
|
|
@@ -325,11 +326,17 @@ write_files: {
|
|
|
325
326
|
label: "npm start",
|
|
326
327
|
run: () => runWithChildProcess("npm start"),
|
|
327
328
|
});
|
|
329
|
+
const packageTemplateObject = JSON.parse(templateFileContent);
|
|
330
|
+
packageTemplateObject.name = urlToFilename(directoryUrl);
|
|
331
|
+
const packageString = JSON.stringify(
|
|
332
|
+
packageTemplateObject,
|
|
333
|
+
null,
|
|
334
|
+
" ",
|
|
335
|
+
);
|
|
336
|
+
writeFileSync(toUrl, packageString);
|
|
337
|
+
} else {
|
|
338
|
+
writeFileSync(toUrl, templateFileContent);
|
|
328
339
|
}
|
|
329
|
-
const packageTemplateObject = JSON.parse(templateFileContent);
|
|
330
|
-
packageTemplateObject.name = urlToFilename(directoryUrl);
|
|
331
|
-
const packageString = JSON.stringify(packageTemplateObject, null, " ");
|
|
332
|
-
writeFileSync(toUrl, packageString);
|
|
333
340
|
continue;
|
|
334
341
|
}
|
|
335
342
|
const relativeUrl = urlToRelativeUrl(fromUrl, templateSourceDirectoryUrl);
|