@netlify/zip-it-and-ship-it 4.23.3 → 4.23.5-setup-typescript-4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/archive.d.ts +8 -0
  2. package/dist/archive.js +39 -0
  3. package/dist/bin.d.ts +2 -0
  4. package/dist/bin.js +67 -0
  5. package/dist/config.d.ts +4 -0
  6. package/dist/config.js +26 -0
  7. package/dist/feature_flags.d.ts +12 -0
  8. package/dist/feature_flags.js +10 -0
  9. package/dist/main.d.ts +15 -0
  10. package/dist/main.js +80 -0
  11. package/dist/manifest.d.ts +4 -0
  12. package/dist/manifest.js +25 -0
  13. package/dist/node_dependencies/index.d.ts +15 -0
  14. package/dist/node_dependencies/index.js +132 -0
  15. package/dist/node_dependencies/module.d.ts +1 -0
  16. package/dist/node_dependencies/module.js +10 -0
  17. package/dist/node_dependencies/nested.d.ts +10 -0
  18. package/{src → dist}/node_dependencies/nested.js +39 -60
  19. package/dist/node_dependencies/package_json.d.ts +1 -0
  20. package/dist/node_dependencies/package_json.js +29 -0
  21. package/dist/node_dependencies/published.d.ts +1 -0
  22. package/dist/node_dependencies/published.js +42 -0
  23. package/dist/node_dependencies/resolve.d.ts +2 -0
  24. package/dist/node_dependencies/resolve.js +114 -0
  25. package/dist/node_dependencies/side_files.d.ts +1 -0
  26. package/dist/node_dependencies/side_files.js +14 -0
  27. package/dist/node_dependencies/special_cases.d.ts +6 -0
  28. package/dist/node_dependencies/special_cases.js +44 -0
  29. package/dist/node_dependencies/traverse.d.ts +39 -0
  30. package/dist/node_dependencies/traverse.js +120 -0
  31. package/dist/node_dependencies/tree_files.d.ts +3 -0
  32. package/dist/node_dependencies/tree_files.js +32 -0
  33. package/dist/node_dependencies/tree_shake.d.ts +1 -0
  34. package/{src → dist}/node_dependencies/tree_shake.js +8 -12
  35. package/dist/runtimes/detect_runtime.d.ts +4 -0
  36. package/dist/runtimes/detect_runtime.js +27 -0
  37. package/dist/runtimes/go/builder.d.ts +12 -0
  38. package/dist/runtimes/go/builder.js +39 -0
  39. package/dist/runtimes/go/index.d.ts +18 -0
  40. package/dist/runtimes/go/index.js +78 -0
  41. package/dist/runtimes/index.d.ts +9 -0
  42. package/dist/runtimes/index.js +87 -0
  43. package/dist/runtimes/node/base_path.d.ts +1 -0
  44. package/dist/runtimes/node/base_path.js +8 -0
  45. package/dist/runtimes/node/bundler.d.ts +20 -0
  46. package/dist/runtimes/node/bundler.js +135 -0
  47. package/dist/runtimes/node/bundler_target.d.ts +1 -0
  48. package/dist/runtimes/node/bundler_target.js +16 -0
  49. package/dist/runtimes/node/detect_es_module.d.ts +3 -0
  50. package/dist/runtimes/node/detect_es_module.js +28 -0
  51. package/dist/runtimes/node/dynamic_imports/parser.d.ts +8 -0
  52. package/dist/runtimes/node/dynamic_imports/parser.js +135 -0
  53. package/dist/runtimes/node/dynamic_imports/plugin.d.ts +10 -0
  54. package/dist/runtimes/node/dynamic_imports/plugin.js +102 -0
  55. package/dist/runtimes/node/finder.d.ts +12 -0
  56. package/dist/runtimes/node/finder.js +82 -0
  57. package/dist/runtimes/node/index.d.ts +16 -0
  58. package/dist/runtimes/node/index.js +118 -0
  59. package/dist/runtimes/node/list_imports.d.ts +4 -0
  60. package/dist/runtimes/node/list_imports.js +68 -0
  61. package/dist/runtimes/node/native_modules/detector.d.ts +7 -0
  62. package/dist/runtimes/node/native_modules/detector.js +14 -0
  63. package/dist/runtimes/node/native_modules/plugin.d.ts +4 -0
  64. package/dist/runtimes/node/native_modules/plugin.js +65 -0
  65. package/dist/runtimes/node/src_files.d.ts +20 -0
  66. package/dist/runtimes/node/src_files.js +84 -0
  67. package/dist/runtimes/node/zip_esbuild.d.ts +22 -0
  68. package/dist/runtimes/node/zip_esbuild.js +95 -0
  69. package/dist/runtimes/node/zip_zisi.d.ts +20 -0
  70. package/dist/runtimes/node/zip_zisi.js +42 -0
  71. package/dist/runtimes/rust/builder.d.ts +9 -0
  72. package/dist/runtimes/rust/builder.js +100 -0
  73. package/dist/runtimes/rust/constants.d.ts +2 -0
  74. package/dist/runtimes/rust/constants.js +3 -0
  75. package/dist/runtimes/rust/index.d.ts +20 -0
  76. package/dist/runtimes/rust/index.js +101 -0
  77. package/dist/utils/consts.d.ts +8 -0
  78. package/dist/utils/consts.js +10 -0
  79. package/dist/utils/fs.d.ts +14 -0
  80. package/dist/utils/fs.js +86 -0
  81. package/dist/utils/polyfills.d.ts +1 -0
  82. package/{src → dist}/utils/polyfills.js +1 -1
  83. package/dist/utils/remove_falsy.d.ts +1 -0
  84. package/dist/utils/remove_falsy.js +9 -0
  85. package/dist/utils/shell.d.ts +2 -0
  86. package/dist/utils/shell.js +2 -0
  87. package/dist/zip.d.ts +15 -0
  88. package/dist/zip.js +116 -0
  89. package/dist/zip_binary.d.ts +7 -0
  90. package/dist/zip_binary.js +20 -0
  91. package/dist/zip_node.d.ts +4 -0
  92. package/dist/zip_node.js +143 -0
  93. package/package.json +19 -13
  94. package/src/archive.js +0 -36
  95. package/src/bin.js +0 -53
  96. package/src/config.js +0 -32
  97. package/src/feature_flags.js +0 -20
  98. package/src/main.js +0 -91
  99. package/src/manifest.js +0 -22
  100. package/src/node_dependencies/index.js +0 -161
  101. package/src/node_dependencies/module.js +0 -13
  102. package/src/node_dependencies/package_json.js +0 -21
  103. package/src/node_dependencies/published.js +0 -37
  104. package/src/node_dependencies/resolve.js +0 -108
  105. package/src/node_dependencies/side_files.js +0 -18
  106. package/src/node_dependencies/special_cases.js +0 -42
  107. package/src/node_dependencies/traverse.js +0 -147
  108. package/src/node_dependencies/tree_files.js +0 -20
  109. package/src/runtimes/detect_runtime.js +0 -20
  110. package/src/runtimes/go/builder.js +0 -37
  111. package/src/runtimes/go/index.js +0 -89
  112. package/src/runtimes/index.js +0 -96
  113. package/src/runtimes/node/base_path.js +0 -11
  114. package/src/runtimes/node/bundler.js +0 -151
  115. package/src/runtimes/node/bundler_target.js +0 -22
  116. package/src/runtimes/node/detect_es_module.js +0 -24
  117. package/src/runtimes/node/dynamic_imports/parser.js +0 -162
  118. package/src/runtimes/node/dynamic_imports/plugin.js +0 -116
  119. package/src/runtimes/node/finder.js +0 -93
  120. package/src/runtimes/node/index.js +0 -122
  121. package/src/runtimes/node/list_imports.js +0 -59
  122. package/src/runtimes/node/native_modules/detector.js +0 -21
  123. package/src/runtimes/node/native_modules/plugin.js +0 -77
  124. package/src/runtimes/node/src_files.js +0 -99
  125. package/src/runtimes/node/zip_esbuild.js +0 -119
  126. package/src/runtimes/node/zip_zisi.js +0 -50
  127. package/src/runtimes/rust/builder.js +0 -114
  128. package/src/runtimes/rust/constants.js +0 -4
  129. package/src/runtimes/rust/index.js +0 -112
  130. package/src/utils/consts.js +0 -10
  131. package/src/utils/fs.js +0 -88
  132. package/src/utils/remove_falsy.js +0 -12
  133. package/src/utils/shell.js +0 -3
  134. package/src/zip.js +0 -161
  135. package/src/zip_binary.js +0 -11
  136. package/src/zip_node.js +0 -179
package/src/utils/fs.js DELETED
@@ -1,88 +0,0 @@
1
- const { lstat, readdir, readFile, unlink, writeFile } = require('fs')
2
- const { format, join, parse, resolve } = require('path')
3
- const { promisify } = require('util')
4
-
5
- const pLstat = promisify(lstat)
6
- const pReaddir = promisify(readdir)
7
- const pReadFile = promisify(readFile)
8
- const pUnlink = promisify(unlink)
9
- const pWriteFile = promisify(writeFile)
10
-
11
- // This caches multiple FS calls to the same path. It creates a cache key with
12
- // the name of the function and the path (e.g. "readdir:/some/directory").
13
- const cachedIOFunction = (func, cache, path, ...args) => {
14
- const key = `${func.name}:${path}`
15
-
16
- if (cache[key] === undefined) {
17
- // eslint-disable-next-line no-param-reassign
18
- cache[key] = func(path, ...args)
19
- }
20
-
21
- return cache[key]
22
- }
23
-
24
- const cachedLstat = (...args) => cachedIOFunction(pLstat, ...args)
25
- const cachedReaddir = (...args) => cachedIOFunction(pReaddir, ...args)
26
- const cachedReadFile = (...args) => cachedIOFunction(pReadFile, ...args)
27
-
28
- const getPathWithExtension = (path, extension) => format({ ...parse(path), base: undefined, ext: extension })
29
-
30
- const safeUnlink = async (path) => {
31
- try {
32
- await pUnlink(path)
33
- } catch (_) {}
34
- }
35
-
36
- // Takes a list of absolute paths and returns an array containing all the
37
- // filenames within those directories, if at least one of the directories
38
- // exists. If not, an error is thrown.
39
- const listFunctionsDirectories = async function (srcFolders) {
40
- const filenamesByDirectory = await Promise.all(
41
- srcFolders.map(async (srcFolder) => {
42
- try {
43
- const filenames = await listFunctionsDirectory(srcFolder)
44
-
45
- return filenames
46
- } catch (error) {
47
- return null
48
- }
49
- }),
50
- )
51
- const validDirectories = filenamesByDirectory.filter(Boolean)
52
-
53
- if (validDirectories.length === 0) {
54
- throw new Error(`Functions folder does not exist: ${srcFolders.join(', ')}`)
55
- }
56
-
57
- return validDirectories.flat()
58
- }
59
-
60
- const listFunctionsDirectory = async function (srcFolder) {
61
- try {
62
- const filenames = await pReaddir(srcFolder)
63
-
64
- return filenames.map((name) => join(srcFolder, name))
65
- } catch (error) {
66
- throw new Error(`Functions folder does not exist: ${srcFolder}`)
67
- }
68
- }
69
-
70
- const resolveFunctionsDirectories = (input) => {
71
- const directories = Array.isArray(input) ? input : [input]
72
- const absoluteDirectories = directories.map((srcFolder) => resolve(srcFolder))
73
-
74
- return absoluteDirectories
75
- }
76
-
77
- module.exports = {
78
- cachedLstat,
79
- cachedReaddir,
80
- cachedReadFile,
81
- lstat: pLstat,
82
- getPathWithExtension,
83
- listFunctionsDirectories,
84
- listFunctionsDirectory,
85
- resolveFunctionsDirectories,
86
- safeUnlink,
87
- writeFile: pWriteFile,
88
- }
@@ -1,12 +0,0 @@
1
- const filterObj = require('filter-obj')
2
-
3
- // Remove falsy values from object
4
- const removeFalsy = function (obj) {
5
- return filterObj(obj, isDefined)
6
- }
7
-
8
- const isDefined = function (key, value) {
9
- return value !== undefined && value !== ''
10
- }
11
-
12
- module.exports = { removeFalsy }
@@ -1,3 +0,0 @@
1
- const execa = require('execa')
2
-
3
- module.exports = { runCommand: execa }
package/src/zip.js DELETED
@@ -1,161 +0,0 @@
1
- const { resolve } = require('path')
2
-
3
- const makeDir = require('make-dir')
4
- const pMap = require('p-map')
5
-
6
- const { getFlags } = require('./feature_flags')
7
- const { createManifest } = require('./manifest')
8
- const { getPluginsModulesPath } = require('./node_dependencies')
9
- const { getFunctionsFromPaths } = require('./runtimes')
10
- const { ARCHIVE_FORMAT_NONE, ARCHIVE_FORMAT_ZIP } = require('./utils/consts')
11
- const { listFunctionsDirectories, resolveFunctionsDirectories } = require('./utils/fs')
12
- const { removeFalsy } = require('./utils/remove_falsy')
13
-
14
- const DEFAULT_PARALLEL_LIMIT = 5
15
-
16
- const validateArchiveFormat = (archiveFormat) => {
17
- if (![ARCHIVE_FORMAT_NONE, ARCHIVE_FORMAT_ZIP].includes(archiveFormat)) {
18
- throw new Error(`Invalid archive format: ${archiveFormat}`)
19
- }
20
- }
21
-
22
- // Takes the result of zipping a function and formats it for output.
23
- const formatZipResult = (result) => {
24
- const {
25
- bundler,
26
- bundlerErrors,
27
- bundlerWarnings,
28
- config = {},
29
- inputs,
30
- mainFile,
31
- name,
32
- nativeNodeModules,
33
- nodeModulesWithDynamicImports,
34
- path,
35
- runtime,
36
- } = result
37
-
38
- return removeFalsy({
39
- bundler,
40
- bundlerErrors,
41
- bundlerWarnings,
42
- config,
43
- inputs,
44
- mainFile,
45
- name,
46
- nativeNodeModules,
47
- nodeModulesWithDynamicImports,
48
- path,
49
- runtime: runtime.name,
50
- })
51
- }
52
-
53
- // Zip `srcFolder/*` (Node.js or Go files) to `destFolder/*.zip` so it can be
54
- // used by AWS Lambda
55
- const zipFunctions = async function (
56
- relativeSrcFolders,
57
- destFolder,
58
- {
59
- archiveFormat = ARCHIVE_FORMAT_ZIP,
60
- basePath,
61
- config = {},
62
- featureFlags: inputFeatureFlags,
63
- manifest,
64
- parallelLimit = DEFAULT_PARALLEL_LIMIT,
65
- } = {},
66
- ) {
67
- validateArchiveFormat(archiveFormat)
68
-
69
- const featureFlags = getFlags(inputFeatureFlags)
70
- const srcFolders = resolveFunctionsDirectories(relativeSrcFolders)
71
- const [paths] = await Promise.all([listFunctionsDirectories(srcFolders), makeDir(destFolder)])
72
- const [functions, pluginsModulesPath] = await Promise.all([
73
- getFunctionsFromPaths(paths, { config, dedupe: true, featureFlags }),
74
-
75
- // All function directories should be part of the same project root, so we
76
- // can get away with computing the plugins modules path from any of the
77
- // source directories.
78
- getPluginsModulesPath(srcFolders[0]),
79
- ])
80
- const results = await pMap(
81
- functions.values(),
82
- async (func) => {
83
- const zipResult = await func.runtime.zipFunction({
84
- archiveFormat,
85
- basePath,
86
- config: func.config,
87
- destFolder,
88
- extension: func.extension,
89
- filename: func.filename,
90
- mainFile: func.mainFile,
91
- name: func.name,
92
- pluginsModulesPath,
93
- runtime: func.runtime,
94
- srcDir: func.srcDir,
95
- srcPath: func.srcPath,
96
- stat: func.stat,
97
- featureFlags,
98
- })
99
-
100
- return { ...zipResult, mainFile: func.mainFile, name: func.name, runtime: func.runtime }
101
- },
102
- {
103
- concurrency: parallelLimit,
104
- },
105
- )
106
- const formattedResults = results.filter(Boolean).map(formatZipResult)
107
-
108
- if (manifest !== undefined) {
109
- await createManifest({ functions: formattedResults, path: resolve(manifest) })
110
- }
111
-
112
- return formattedResults
113
- }
114
-
115
- const zipFunction = async function (
116
- relativeSrcPath,
117
- destFolder,
118
- {
119
- archiveFormat = ARCHIVE_FORMAT_ZIP,
120
- basePath,
121
- config: inputConfig = {},
122
- featureFlags: inputFeatureFlags,
123
- pluginsModulesPath: defaultModulesPath,
124
- } = {},
125
- ) {
126
- validateArchiveFormat(archiveFormat)
127
-
128
- const featureFlags = getFlags(inputFeatureFlags)
129
- const srcPath = resolve(relativeSrcPath)
130
- const functions = await getFunctionsFromPaths([srcPath], { config: inputConfig, dedupe: true, featureFlags })
131
-
132
- if (functions.size === 0) {
133
- return
134
- }
135
-
136
- const { config, extension, filename, mainFile, name, runtime, srcDir, stat } = functions.values().next().value
137
- const pluginsModulesPath =
138
- defaultModulesPath === undefined ? await getPluginsModulesPath(srcPath) : defaultModulesPath
139
-
140
- await makeDir(destFolder)
141
-
142
- const zipResult = await runtime.zipFunction({
143
- archiveFormat,
144
- basePath,
145
- config,
146
- srcPath,
147
- destFolder,
148
- mainFile,
149
- filename,
150
- extension,
151
- srcDir,
152
- stat,
153
- runtime,
154
- pluginsModulesPath,
155
- featureFlags,
156
- })
157
-
158
- return formatZipResult({ ...zipResult, mainFile, name, runtime })
159
- }
160
-
161
- module.exports = { zipFunction, zipFunctions }
package/src/zip_binary.js DELETED
@@ -1,11 +0,0 @@
1
- const { startZip, addZipFile, addZipContent, endZip } = require('./archive')
2
-
3
- // Zip a binary function file
4
- const zipBinary = async function ({ srcPath, destPath, filename, stat, runtime }) {
5
- const { archive, output } = startZip(destPath)
6
- addZipFile(archive, srcPath, filename, stat)
7
- addZipContent(archive, JSON.stringify({ runtime: runtime.name }), 'netlify-toolchain')
8
- await endZip(archive, output)
9
- }
10
-
11
- module.exports = { zipBinary }
package/src/zip_node.js DELETED
@@ -1,179 +0,0 @@
1
- const { Buffer } = require('buffer')
2
- const fs = require('fs')
3
- const os = require('os')
4
- const { basename, extname, join, normalize, resolve, sep } = require('path')
5
- const { promisify } = require('util')
6
-
7
- const copyFile = require('cp-file')
8
- const deleteFiles = require('del')
9
- const makeDir = require('make-dir')
10
- const pMap = require('p-map')
11
- const unixify = require('unixify')
12
-
13
- const { startZip, addZipFile, addZipContent, endZip } = require('./archive')
14
- const { ARCHIVE_FORMAT_ZIP } = require('./utils/consts')
15
-
16
- const pStat = promisify(fs.stat)
17
- const pWriteFile = promisify(fs.writeFile)
18
-
19
- // Taken from https://www.npmjs.com/package/cpy.
20
- const COPY_FILE_CONCURRENCY = os.cpus().length === 0 ? 2 : os.cpus().length * 2
21
-
22
- // Sub-directory to place all user-defined files (i.e. everything other than
23
- // the entry file generated by zip-it-and-ship-it).
24
- const DEFAULT_USER_SUBDIRECTORY = 'src'
25
-
26
- const createDirectory = async function ({
27
- aliases = new Map(),
28
- basePath,
29
- destFolder,
30
- extension,
31
- filename,
32
- mainFile,
33
- pluginsModulesPath,
34
- srcFiles,
35
- }) {
36
- const { contents: entryContents, filename: entryFilename } = getEntryFile({
37
- commonPrefix: basePath,
38
- filename,
39
- mainFile,
40
- userNamespace: DEFAULT_USER_SUBDIRECTORY,
41
- })
42
- const functionFolder = join(destFolder, basename(filename, extension))
43
-
44
- // Deleting the functions directory in case it exists before creating it.
45
- await deleteFiles(functionFolder, { force: true })
46
- await makeDir(functionFolder)
47
-
48
- // Writing entry file.
49
- await pWriteFile(join(functionFolder, entryFilename), entryContents)
50
-
51
- // Copying source files.
52
- await pMap(
53
- srcFiles,
54
- (srcFile) => {
55
- const srcPath = aliases.get(srcFile) || srcFile
56
- const normalizedSrcPath = normalizeFilePath({
57
- commonPrefix: basePath,
58
- path: srcPath,
59
- pluginsModulesPath,
60
- userNamespace: DEFAULT_USER_SUBDIRECTORY,
61
- })
62
- const destPath = join(functionFolder, normalizedSrcPath)
63
-
64
- return copyFile(srcFile, destPath)
65
- },
66
- { concurrency: COPY_FILE_CONCURRENCY },
67
- )
68
-
69
- return functionFolder
70
- }
71
-
72
- const createZipArchive = async function ({
73
- aliases,
74
- basePath,
75
- destFolder,
76
- extension,
77
- filename,
78
- mainFile,
79
- pluginsModulesPath,
80
- srcFiles,
81
- }) {
82
- const destPath = join(destFolder, `${basename(filename, extension)}.zip`)
83
- const { archive, output } = startZip(destPath)
84
- const entryFilename = `${basename(filename, extension)}.js`
85
- const entryFilePath = resolve(basePath, entryFilename)
86
-
87
- // We don't need an entry file if it would end up with the same path as the
88
- // function's main file.
89
- const needsEntryFile = entryFilePath !== mainFile
90
-
91
- // There is a naming conflict with the entry file if one of the supporting
92
- // files (i.e. not the main file) has the path that the entry file needs to
93
- // take.
94
- const hasEntryFileConflict = srcFiles.some((srcFile) => srcFile === entryFilePath && srcFile !== mainFile)
95
-
96
- // If there is a naming conflict, we move all user files (everything other
97
- // than the entry file) to its own sub-directory.
98
- const userNamespace = hasEntryFileConflict ? DEFAULT_USER_SUBDIRECTORY : ''
99
-
100
- if (needsEntryFile) {
101
- const entryFile = getEntryFile({ commonPrefix: basePath, filename, mainFile, userNamespace })
102
-
103
- addEntryFileToZip(archive, entryFile)
104
- }
105
-
106
- const srcFilesInfos = await Promise.all(srcFiles.map(addStat))
107
-
108
- // We ensure this is not async, so that the archive's checksum is
109
- // deterministic. Otherwise it depends on the order the files were added.
110
- srcFilesInfos.forEach(({ srcFile, stat }) => {
111
- zipJsFile({ srcFile, commonPrefix: basePath, pluginsModulesPath, archive, stat, aliases, userNamespace })
112
- })
113
-
114
- await endZip(archive, output)
115
-
116
- return destPath
117
- }
118
-
119
- const zipNodeJs = function ({ archiveFormat, ...options }) {
120
- if (archiveFormat === ARCHIVE_FORMAT_ZIP) {
121
- return createZipArchive(options)
122
- }
123
-
124
- return createDirectory(options)
125
- }
126
-
127
- const addEntryFileToZip = function (archive, { contents, filename }) {
128
- const contentBuffer = Buffer.from(contents)
129
-
130
- addZipContent(archive, contentBuffer, filename)
131
- }
132
-
133
- const addStat = async function (srcFile) {
134
- const stat = await pStat(srcFile)
135
- return { srcFile, stat }
136
- }
137
-
138
- const getEntryFile = ({ commonPrefix, filename, mainFile, userNamespace }) => {
139
- const mainPath = normalizeFilePath({ commonPrefix, path: mainFile, userNamespace })
140
- const extension = extname(filename)
141
- const entryFilename = `${basename(filename, extension)}.js`
142
-
143
- return {
144
- contents: `module.exports = require('.${mainPath.startsWith('/') ? mainPath : `/${mainPath}`}')`,
145
- filename: entryFilename,
146
- }
147
- }
148
-
149
- const zipJsFile = function ({
150
- srcFile,
151
- commonPrefix,
152
- pluginsModulesPath,
153
- archive,
154
- stat,
155
- aliases = new Map(),
156
- userNamespace,
157
- }) {
158
- const filename = aliases.get(srcFile) || srcFile
159
- const normalizedFilename = normalizeFilePath({ commonPrefix, path: filename, pluginsModulesPath, userNamespace })
160
-
161
- addZipFile(archive, srcFile, normalizedFilename, stat)
162
- }
163
-
164
- // `adm-zip` and `require()` expect Unix paths.
165
- // We remove the common path prefix.
166
- // With files on different Windows drives, we remove the drive letter.
167
- const normalizeFilePath = function ({ commonPrefix, path, pluginsModulesPath, userNamespace }) {
168
- const userNamespacePathSegment = userNamespace ? `${userNamespace}${sep}` : ''
169
- const pathA = normalize(path)
170
- const pathB =
171
- pluginsModulesPath === undefined
172
- ? pathA
173
- : pathA.replace(pluginsModulesPath, `${userNamespacePathSegment}node_modules`)
174
- const pathC = pathB.replace(commonPrefix, userNamespacePathSegment)
175
- const pathD = unixify(pathC)
176
- return pathD
177
- }
178
-
179
- module.exports = { zipNodeJs }