forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
after-pack-hook.js
40 lines (32 loc) · 1.29 KB
/
after-pack-hook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* eslint-disable no-console */
const fs = require('fs-extra')
const { join } = require('path')
const globby = require('globby')
const os = require('os')
module.exports = async function (params) {
console.log('****************************')
console.log('After pack hook')
console.log(params.appOutDir)
console.log(params.outDir)
console.log(params.electronPlatformName)
console.log('****************************')
const packages = await globby('packages/*/node_modules', {
cwd: params.packager.info._appDir,
onlyFiles: false,
})
const buildSubfoldersPerPlatform = {
darwin: join('Cypress.app', 'Contents', 'Resources', 'app'),
linux: join('resources', 'app'),
win32: join('resources', 'app'), // TODO check this path
}
const buildSubfolder = buildSubfoldersPerPlatform[os.platform()]
const outputFolder = join(params.appOutDir, buildSubfolder)
console.log('copying node_modules to', outputFolder)
for await (const packageNodeModules of packages) {
console.log('copying', packageNodeModules)
const sourceFolder = join(params.packager.info._appDir, packageNodeModules)
const destinationFolder = join(outputFolder, packageNodeModules)
await fs.copy(sourceFolder, destinationFolder)
}
console.log('all node_modules subfolders copied to', outputFolder)
}