gistajs 0.0.2 → 0.0.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/dist/bin.cjs CHANGED
@@ -204,7 +204,7 @@ async function createProject(starter, options) {
204
204
  await extractStarter(archivePath, extractRoot);
205
205
  let extracted = await findExtractedRoot(extractRoot);
206
206
  await assertSafeProjectRoot(root);
207
- await (0, import_promises2.rename)(extracted, root);
207
+ await copyProject(extracted, root);
208
208
  await rewritePackageName(root, (0, import_node_path.basename)(root));
209
209
  if (options.git !== false) {
210
210
  await initGit(root, starter);
@@ -266,6 +266,23 @@ async function rewritePackageName(root, projectName) {
266
266
  `);
267
267
  }
268
268
  }
269
+ async function copyProject(source, destination) {
270
+ try {
271
+ await (0, import_promises2.rename)(source, destination);
272
+ return;
273
+ } catch (error) {
274
+ if (!shouldFallbackToCopy(error)) throw error;
275
+ }
276
+ await (0, import_promises2.cp)(source, destination, {
277
+ recursive: true,
278
+ force: false,
279
+ errorOnExist: true
280
+ });
281
+ }
282
+ function shouldFallbackToCopy(error) {
283
+ let code = error?.code;
284
+ return code === "EXDEV" || code === "EPERM";
285
+ }
269
286
  async function assertEmptyTarget(root) {
270
287
  try {
271
288
  await (0, import_promises2.stat)(root);
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ function parseStarter(data) {
33
33
 
34
34
  // src/create.ts
35
35
  import {
36
+ cp,
36
37
  mkdtemp,
37
38
  mkdir,
38
39
  readdir,
@@ -188,7 +189,7 @@ async function createProject(starter, options) {
188
189
  await extractStarter(archivePath, extractRoot);
189
190
  let extracted = await findExtractedRoot(extractRoot);
190
191
  await assertSafeProjectRoot(root);
191
- await rename(extracted, root);
192
+ await copyProject(extracted, root);
192
193
  await rewritePackageName(root, basename(root));
193
194
  if (options.git !== false) {
194
195
  await initGit(root, starter);
@@ -250,6 +251,23 @@ async function rewritePackageName(root, projectName) {
250
251
  `);
251
252
  }
252
253
  }
254
+ async function copyProject(source, destination) {
255
+ try {
256
+ await rename(source, destination);
257
+ return;
258
+ } catch (error) {
259
+ if (!shouldFallbackToCopy(error)) throw error;
260
+ }
261
+ await cp(source, destination, {
262
+ recursive: true,
263
+ force: false,
264
+ errorOnExist: true
265
+ });
266
+ }
267
+ function shouldFallbackToCopy(error) {
268
+ let code = error?.code;
269
+ return code === "EXDEV" || code === "EPERM";
270
+ }
253
271
  async function assertEmptyTarget(root) {
254
272
  try {
255
273
  await stat(root);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gistajs",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Create Gista.js starter projects",
5
5
  "keywords": [
6
6
  "cli",