Skip to content

Commit

Permalink
fs.cp w recursive and force is roughly cpr w overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
tbeseda committed Jul 31, 2024
1 parent 5cc4e43 commit ca9fcd0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

- name: Set up bundle
run: |
gem install bundler -v 1.17.3
gem install bundler -v 1.17.3 # Bundler 2.x breaks test lockfile
bundle config jobs 4
bundle config retry 3
Expand Down
2 changes: 1 addition & 1 deletion src/shared/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function copy (source, destination, params, callback) {
}
else {
// cpr(source, destination, { overwrite: true }, callback)
cp(source, destination, { recursive: true }, callback)
cp(source, destination, { recursive: true, force: true }, callback)
}
}
catch (err) {
Expand Down
10 changes: 5 additions & 5 deletions test/integration/_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ let viewsArtifactsDisabled = [
function reset (t, callback) {
process.chdir(join(__dirname, '..'))
destroyPath(mockTmp)
cp(mockSource, mockTmp, { recursive: true }, function (err) {
cp(mockSource, mockTmp, { recursive: true, force: 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', { recursive: true }, function done (err) {
cp('_shared', 'src', { recursive: true, force: true }, function done (err) {
if (err) t.fail(err)
else callback()
})
})
}
function resetAndCopySharedAutoinstall (t, callback) {
reset(t, function () {
cp('_shared-autoinstall', '.', { recursive: true }, function done (err) {
cp('_shared-autoinstall', '.', { recursive: true, force: true }, function done (err) {
if (err) t.fail(err)
else callback()
})
})
}
function resetAndCopySharedCustom (t, callback) {
reset(t, function () {
cp('_shared-custom', '.', { recursive: true }, function done (err) {
cp('_shared-custom', '.', { recursive: true, force: true }, function done (err) {
if (err) t.fail(err)
else callback()
})
})
}
function resetAndCopySharedPlugins (t, callback) {
reset(t, function () {
cp('_shared-plugins', 'src', { recursive: true }, function done (err) {
cp('_shared-plugins', 'src', { recursive: true, force: true }, function done (err) {
if (err) t.fail(err)
else callback()
})
Expand Down
6 changes: 3 additions & 3 deletions test/integration/default/shared-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,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'), { recursive: true },
cp(join('src', 'app.plugins'), join('.', 'app.arc'), { recursive: true, force: true },
function (err) {
if (err) t.fail(err)
else {
Expand Down Expand Up @@ -183,7 +183,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'), { recursive: true }, function (err) {
cp(join('src', 'app.arc-views'), join('.', 'app.arc'), { recursive: true, force: true }, function (err) {
if (err) t.fail(err)
else {
hydrate.shared({}, function (err) {
Expand Down Expand Up @@ -212,7 +212,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'), { recursive: true }, function (err) {
cp(join('_shared-custom', 'app.arc-views'), join('.', 'app.arc'), { recursive: true, force: true }, function (err) {
if (err) t.fail(err)
else {
hydrate.shared({}, function (err) {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/symlink/shared-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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'), { recursive: true },
cp(join('src', 'app.plugins'), join('.', 'app.arc'), { recursive: true, force: true },
function (err) {
if (err) t.fail(err)
else {
Expand Down Expand Up @@ -187,7 +187,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'), { recursive: true }, function (err) {
cp(join('src', 'app.arc-views'), join('.', 'app.arc'), { recursive: true, force: true }, function (err) {
if (err) t.fail(err)
else {
hydrate.shared({ symlink }, function (err) {
Expand Down Expand Up @@ -216,7 +216,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'), { recursive: true }, function (err) {
cp(join('_shared-custom', 'app.arc-views'), join('.', 'app.arc'), { recursive: true, force: true }, function (err) {
if (err) t.fail(err)
else {
hydrate.shared({ symlink }, function (err) {
Expand Down

0 comments on commit ca9fcd0

Please sign in to comment.