Skip to content

Commit

Permalink
try using fs.cp
Browse files Browse the repository at this point in the history
available in Node 16.7
  • Loading branch information
tbeseda committed Jul 23, 2024
1 parent b8c6806 commit 79c5cb7
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
8 changes: 5 additions & 3 deletions src/shared/copy.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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) {
Expand Down
14 changes: 7 additions & 7 deletions test/integration/_shared.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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)
Expand All @@ -163,31 +163,31 @@ 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()
})
})
}
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()
})
})
}
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()
})
})
}
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()
})
Expand Down
9 changes: 5 additions & 4 deletions test/integration/default/shared-tests.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
let { dirname, join } = require('path')
let {
cp,
existsSync,
lstatSync,
mkdirSync,
readFileSync,
renameSync,
writeFileSync,
} = require('fs')
let cp = require('cpr')
// let cp = require('cpr')
let test = require('tape')
let {
resetAndCopyShared,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 5 additions & 4 deletions test/integration/symlink/shared-tests.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
let { dirname, join } = require('path')
let {
cp,
existsSync,
lstatSync,
mkdirSync,
readFileSync,
renameSync,
writeFileSync,
} = require('fs')
let cp = require('cpr')
// let cp = require('cpr')
let test = require('tape')
let {
resetAndCopyShared,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 79c5cb7

Please sign in to comment.