1
- const fs = require ( 'fs-extra' )
2
1
const path = require ( 'path' )
3
2
const process = require ( 'process' )
4
- const { promisify } = require ( 'util' )
5
- const { copy } = require ( 'cpx' )
6
3
const nextOnNetlify = require ( 'next-on-netlify' )
7
4
const pathExists = require ( 'path-exists' )
8
5
const { dir : getTmpDir } = require ( 'tmp-promise' )
9
6
const execa = require ( 'execa' )
7
+ const cpy = require ( 'cpy' )
10
8
11
9
const plugin = require ( '..' )
12
10
13
- const pCopy = promisify ( copy )
14
-
15
11
const FIXTURES_DIR = `${ __dirname } /fixtures`
16
12
const SAMPLE_PROJECT_DIR = `${ __dirname } /sample`
17
13
@@ -34,15 +30,14 @@ const changeCwd = function (cwd) {
34
30
}
35
31
36
32
// 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 } )
40
35
}
41
36
42
37
// Copy fixture files to the current directory
43
38
const useFixture = async function ( fixtureName ) {
44
39
const fixtureDir = `${ FIXTURES_DIR } /${ fixtureName } `
45
- await pCopy ( ` ${ fixtureDir } /**` , process . cwd ( ) )
40
+ await cpy ( '**' , process . cwd ( ) , { cwd : fixtureDir , parents : true , overwrite : false , dot : true } )
46
41
}
47
42
48
43
// Build the sample project before running the tests
@@ -167,7 +162,7 @@ describe('preBuild()', () => {
167
162
describe ( 'onBuild()' , ( ) => {
168
163
test ( 'copy files to the publish directory' , async ( ) => {
169
164
await useFixture ( 'publish_copy_files' )
170
- moveNextDist ( )
165
+ await moveNextDist ( )
171
166
const PUBLISH_DIR = 'publish'
172
167
await plugin . onBuild ( {
173
168
constants : {
@@ -185,7 +180,7 @@ describe('onBuild()', () => {
185
180
{ FUNCTIONS_SRC : undefined , resolvedFunctions : 'netlify-automatic-functions' } ,
186
181
] ) ( 'copy files to the functions directory' , async ( { FUNCTIONS_SRC , resolvedFunctions } ) => {
187
182
await useFixture ( 'functions_copy_files' )
188
- moveNextDist ( )
183
+ await moveNextDist ( )
189
184
await plugin . onBuild ( {
190
185
constants : {
191
186
FUNCTIONS_SRC ,
0 commit comments