Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b099569

Browse files
committedNov 30, 2020
Fix files copy
1 parent 9fff034 commit b099569

File tree

3 files changed

+601
-447
lines changed

3 files changed

+601
-447
lines changed
 

‎package-lock.json

Lines changed: 594 additions & 435 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"devDependencies": {
3535
"@netlify/eslint-config-node": "^0.3.0",
36-
"cpx": "^1.5.0",
36+
"cpy": "^8.1.1",
3737
"execa": "^4.1.0",
3838
"husky": "^4.3.0",
3939
"jest": "^26.6.1",

‎test/index.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
const fs = require('fs-extra')
21
const path = require('path')
32
const process = require('process')
4-
const { promisify } = require('util')
5-
const { copy } = require('cpx')
63
const nextOnNetlify = require('next-on-netlify')
74
const pathExists = require('path-exists')
85
const { dir: getTmpDir } = require('tmp-promise')
96
const execa = require('execa')
7+
const cpy = require('cpy')
108

119
const plugin = require('..')
1210

13-
const pCopy = promisify(copy)
14-
1511
const FIXTURES_DIR = `${__dirname}/fixtures`
1612
const SAMPLE_PROJECT_DIR = `${__dirname}/sample`
1713

@@ -34,15 +30,14 @@ const changeCwd = function (cwd) {
3430
}
3531

3632
// Move .next from sample project to current directory
37-
const moveNextDist = function () {
38-
// Use copySync because cpx won't copy hidden files
39-
fs.copySync(`${SAMPLE_PROJECT_DIR}/.next`, `.next`)
33+
const moveNextDist = async function () {
34+
await cpy('**', process.cwd(), { cwd: SAMPLE_PROJECT_DIR, parents: true, overwrite: false, dot: true })
4035
}
4136

4237
// Copy fixture files to the current directory
4338
const useFixture = async function (fixtureName) {
4439
const fixtureDir = `${FIXTURES_DIR}/${fixtureName}`
45-
await pCopy(`${fixtureDir}/**`, process.cwd())
40+
await cpy('**', process.cwd(), { cwd: fixtureDir, parents: true, overwrite: false, dot: true })
4641
}
4742

4843
// Build the sample project before running the tests
@@ -167,7 +162,7 @@ describe('preBuild()', () => {
167162
describe('onBuild()', () => {
168163
test('copy files to the publish directory', async () => {
169164
await useFixture('publish_copy_files')
170-
moveNextDist()
165+
await moveNextDist()
171166
const PUBLISH_DIR = 'publish'
172167
await plugin.onBuild({
173168
constants: {
@@ -185,7 +180,7 @@ describe('onBuild()', () => {
185180
{ FUNCTIONS_SRC: undefined, resolvedFunctions: 'netlify-automatic-functions' },
186181
])('copy files to the functions directory', async ({ FUNCTIONS_SRC, resolvedFunctions }) => {
187182
await useFixture('functions_copy_files')
188-
moveNextDist()
183+
await moveNextDist()
189184
await plugin.onBuild({
190185
constants: {
191186
FUNCTIONS_SRC,

0 commit comments

Comments
 (0)
Please sign in to comment.