From 79c5cb77ec88b3abe9e60cf328b7146724ed1b9c Mon Sep 17 00:00:00 2001 From: Taylor Beseda Date: Mon, 22 Jul 2024 18:57:54 -0600 Subject: [PATCH] try using fs.cp available in Node 16.7 --- package.json | 5 ++--- src/shared/copy.js | 8 +++++--- test/integration/_shared.js | 14 +++++++------- test/integration/default/shared-tests.js | 9 +++++---- test/integration/symlink/shared-tests.js | 9 +++++---- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 369a4d5..67085fa 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "@architect/utils": "~4.0.6", "acorn-loose": "~8.4.0", "chalk": "4.1.2", - "cpr": "~3.0.1", "esquery": "~1.5.0", "glob": "~10.3.12", "minimist": "~1.2.8", @@ -49,13 +48,13 @@ "devDependencies": { "@architect/eslint-config": "~3.0.0", "cross-env": "~7.0.3", - "eslint": "~9.1.1", + "eslint": "~9.7.0", "mock-tmp": "~0.0.4", "nyc": "^15.1.0", "pnpm": "~8.15.5", "proxyquire": "~2.1.3", "tap-arc": "~1.2.2", - "tape": "~5.7.5", + "tape": "~5.8.1", "yarn": "~1.22.22" } } diff --git a/src/shared/copy.js b/src/shared/copy.js index 5130dcf..8b3b4b4 100644 --- a/src/shared/copy.js +++ b/src/shared/copy.js @@ -1,5 +1,5 @@ -let cp = require('cpr') -let { mkdirSync } = require('fs') +// let cpr = require('cpr') +let { cp, mkdirSync } = require('fs') let { dirname } = require('path') let { sync: symlinkOrCopy } = require('symlink-or-copy') let { destroyPath } = require('../lib') @@ -17,7 +17,9 @@ module.exports = function copy (source, destination, params, callback) { callback() } else { - cp(source, destination, { overwrite: true }, callback) + console.log('>>>> RUNNING cp', source, destination) + // cpr(source, destination, { overwrite: true }, callback) + cp(source, destination, { recursive: true }, callback) } } catch (err) { diff --git a/test/integration/_shared.js b/test/integration/_shared.js index 05676c3..514161c 100644 --- a/test/integration/_shared.js +++ b/test/integration/_shared.js @@ -1,6 +1,6 @@ let { dirname, join } = require('path') -let { existsSync } = require('fs') -let cp = require('cpr') +let { cp, existsSync } = require('fs') +// let cp = require('cpr') let { globSync } = require('glob') let { pathToUnix } = require('@architect/utils') let { destroyPath } = require('../../src/lib') @@ -153,7 +153,7 @@ let viewsArtifactsDisabled = [ function reset (t, callback) { process.chdir(join(__dirname, '..')) destroyPath(mockTmp) - cp(mockSource, mockTmp, { overwrite: true }, function (err) { + cp(mockSource, mockTmp, { recursive: true }, function (err) { if (err) t.fail(err) else { process.chdir(mockTmp) @@ -163,7 +163,7 @@ function reset (t, callback) { } function resetAndCopyShared (t, callback) { reset(t, function () { - cp('_shared', 'src', { overwrite: true }, function done (err) { + cp('_shared', 'src', { recursive: true }, function done (err) { if (err) t.fail(err) else callback() }) @@ -171,7 +171,7 @@ function resetAndCopyShared (t, callback) { } function resetAndCopySharedAutoinstall (t, callback) { reset(t, function () { - cp('_shared-autoinstall', '.', { overwrite: true }, function done (err) { + cp('_shared-autoinstall', '.', { recursive: true }, function done (err) { if (err) t.fail(err) else callback() }) @@ -179,7 +179,7 @@ function resetAndCopySharedAutoinstall (t, callback) { } function resetAndCopySharedCustom (t, callback) { reset(t, function () { - cp('_shared-custom', '.', { overwrite: true }, function done (err) { + cp('_shared-custom', '.', { recursive: true }, function done (err) { if (err) t.fail(err) else callback() }) @@ -187,7 +187,7 @@ function resetAndCopySharedCustom (t, callback) { } function resetAndCopySharedPlugins (t, callback) { reset(t, function () { - cp('_shared-plugins', 'src', { overwrite: true }, function done (err) { + cp('_shared-plugins', 'src', { recursive: true }, function done (err) { if (err) t.fail(err) else callback() }) diff --git a/test/integration/default/shared-tests.js b/test/integration/default/shared-tests.js index 0c75701..8c06521 100644 --- a/test/integration/default/shared-tests.js +++ b/test/integration/default/shared-tests.js @@ -1,5 +1,6 @@ let { dirname, join } = require('path') let { + cp, existsSync, lstatSync, mkdirSync, @@ -7,7 +8,7 @@ let { renameSync, writeFileSync, } = require('fs') -let cp = require('cpr') +// let cp = require('cpr') let test = require('tape') let { resetAndCopyShared, @@ -102,7 +103,7 @@ test(`[Shared file copying with plugins (default paths)] shared() copies shared pluginArtifacts.length + 1, ) resetAndCopySharedPlugins(t, function () { - cp(join('src', 'app.plugins'), join('.', 'app.arc'), { overwrite: true }, + cp(join('src', 'app.plugins'), join('.', 'app.arc'), { recursive: true }, function (err) { if (err) t.fail(err) else { @@ -177,7 +178,7 @@ test(`[Shared file copying (custom paths)] shared() copies shared and views (unl test(`[Shared file copying (default paths)] shared() views to only @views (unless disabled or folder not found)`, t => { t.plan(viewsArtifacts.length + viewsArtifactsDisabled.length + 1) resetAndCopyShared(t, function () { - cp(join('src', 'app.arc-views'), join('.', 'app.arc'), { overwrite: true }, function (err) { + cp(join('src', 'app.arc-views'), join('.', 'app.arc'), { recursive: true }, function (err) { if (err) t.fail(err) else { hydrate.shared({}, function (err) { @@ -206,7 +207,7 @@ test(`[Shared file copying (default paths)] shared() views to only @views (unles test(`[Shared file copying (custom paths)] shared() views to only @views (unless disabled or folder not found)`, t => { t.plan(viewsArtifacts.length + viewsArtifactsDisabled.length + 1) resetAndCopySharedCustom(t, function () { - cp(join('_shared-custom', 'app.arc-views'), join('.', 'app.arc'), { overwrite: true }, function (err) { + cp(join('_shared-custom', 'app.arc-views'), join('.', 'app.arc'), { recursive: true }, function (err) { if (err) t.fail(err) else { hydrate.shared({}, function (err) { diff --git a/test/integration/symlink/shared-tests.js b/test/integration/symlink/shared-tests.js index ca41738..889b0a7 100644 --- a/test/integration/symlink/shared-tests.js +++ b/test/integration/symlink/shared-tests.js @@ -1,5 +1,6 @@ let { dirname, join } = require('path') let { + cp, existsSync, lstatSync, mkdirSync, @@ -7,7 +8,7 @@ let { renameSync, writeFileSync, } = require('fs') -let cp = require('cpr') +// let cp = require('cpr') let test = require('tape') let { resetAndCopyShared, @@ -106,7 +107,7 @@ test(`[Shared file symlinking with plugins (default paths)] shared() copies shar pluginArtifacts.length + 1, ) resetAndCopySharedPlugins(t, function () { - cp(join('src', 'app.plugins'), join('.', 'app.arc'), { overwrite: true }, + cp(join('src', 'app.plugins'), join('.', 'app.arc'), { recursive: true }, function (err) { if (err) t.fail(err) else { @@ -181,7 +182,7 @@ test(`[Shared file symlinking (custom paths)] shared() copies shared and views ( test(`[Shared file symlinking (default paths)] shared() views to only @views (unless disabled or folder not found)`, t => { t.plan(viewsArtifacts.length + viewsArtifactsDisabled.length + 1) resetAndCopyShared(t, function () { - cp(join('src', 'app.arc-views'), join('.', 'app.arc'), { overwrite: true }, function (err) { + cp(join('src', 'app.arc-views'), join('.', 'app.arc'), { recursive: true }, function (err) { if (err) t.fail(err) else { hydrate.shared({ symlink }, function (err) { @@ -210,7 +211,7 @@ test(`[Shared file symlinking (default paths)] shared() views to only @views (un test(`[Shared file symlinking (custom paths)] shared() views to only @views (unless disabled or folder not found)`, t => { t.plan(viewsArtifacts.length + viewsArtifactsDisabled.length + 1) resetAndCopySharedCustom(t, function () { - cp(join('_shared-custom', 'app.arc-views'), join('.', 'app.arc'), { overwrite: true }, function (err) { + cp(join('_shared-custom', 'app.arc-views'), join('.', 'app.arc'), { recursive: true }, function (err) { if (err) t.fail(err) else { hydrate.shared({ symlink }, function (err) {