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EAAJ,EAA4C;AAC1C,yBAAK,IAAL,CAAU,IAAV;AACA,2BAAO,IAAP;AACD,mBAHD,MAIK;AACH,2BAAO,QAAP;AACD;AACF,iBAVI,CAAP;AAWD;AACF,aAhCI,CAAP;AAiCD,WArE6B,EAqE3B,iBArE2B,CAA9B;;AAuEA,eAAK,MAAM,KAAX,IAAoB,eAApB,EAAqC;AACnC,gBAAI,SAAS,IAAb,EAAmB;AACjB,qBAAO,IAAP,CAAY,KAAZ;AACD;AACF;;AAED,eAAK,IAAL;;AACA,eAAK,MAAM,KAAX,IAAoB,IAApB,EAA0B;AACxB,kBAAM,IAAN,CAAW,UAAU,KAAK,GAAf,GAAqB,KAAhC;AACD;AACF;AACF;;AACD,aAAO,MAAP;AAnH4G;AAoH7G;;AAzHqD,C","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { CONCURRENCY } from \"builder-util/out/fs\"\nimport { lstat, readdir } from \"fs-extra-p\"\nimport * as path from \"path\"\nimport { excludedNames, FileMatcher } from \"../fileMatcher\"\nimport { Packager } from \"../packager\"\nimport { resolveFunction } from \"../platformPackager\"\nimport { FileCopyHelper } from \"./AppFileWalker\"\n\nconst excludedFiles = new Set([\".DS_Store\", \"node_modules\" /* already in the queue */, \"CHANGELOG.md\", \"ChangeLog\", \"changelog.md\", \"binding.gyp\", \".npmignore\"].concat(excludedNames.split(\",\")))\nconst topLevelExcludedFiles = new Set([\"test.js\", \"karma.conf.js\", \".coveralls.yml\", \"README.md\", \"readme.markdown\", \"README\", \"readme.md\", \"readme\", \"test\", \"__tests__\", \"tests\", \"powered-test\", \"example\", \"examples\"])\n\n/** @internal */\nexport class NodeModuleCopyHelper extends FileCopyHelper {\n constructor(matcher: FileMatcher, packager: Packager) {\n super(matcher, matcher.isEmpty() ? null : matcher.createFilter(), packager)\n }\n\n async collectNodeModules(baseDir: string, moduleNames: Iterable<string>, nodeModuleExcludedExts: Array<string>): Promise<Array<string>> {\n const filter = this.filter\n const metadata = this.metadata\n\n const onNodeModuleFile = resolveFunction(this.packager.config.onNodeModuleFile, \"onNodeModuleFile\")\n\n const result: Array<string> = []\n const queue: Array<string> = []\n for (const moduleName of moduleNames) {\n const tmpPath = baseDir + path.sep + moduleName\n queue.length = 1\n // The path should be corrected in Windows that when the moduleName is Scoped packages named.\n const depPath = path.normalize(tmpPath)\n queue[0] = depPath\n\n // if (dep.link != null) {\n // this.metadata.set(dep.path, dep.stat!)\n // const r = this.handleSymlink(dep.stat!, dep.path, dep.link!)\n // if (r != null) {\n // await r\n // }\n // }\n\n while (queue.length > 0) {\n const dirPath = queue.pop()!\n\n const childNames = await readdir(dirPath)\n childNames.sort()\n\n const isTopLevel = dirPath === depPath\n const dirs: Array<string> = []\n // our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map\n const sortedFilePaths = await BluebirdPromise.map(childNames, name => {\n if (onNodeModuleFile != null) {\n onNodeModuleFile(dirPath + path.sep + name)\n }\n\n if (excludedFiles.has(name) || name.startsWith(\"._\")) {\n return null\n }\n\n for (const ext of nodeModuleExcludedExts) {\n if (name.endsWith(ext)) {\n return null\n }\n }\n\n // noinspection SpellCheckingInspection\n if (isTopLevel && (topLevelExcludedFiles.has(name) || (moduleName === \"libui-node\" && (name === \"build\" || name === \"docs\" || name === \"src\")))) {\n return null\n }\n\n if (dirPath.endsWith(\"build\")) {\n if (name === \"gyp-mac-tool\" || name === \"Makefile\" || name.endsWith(\".mk\") || name.endsWith(\".gypi\") || name.endsWith(\".Makefile\")) {\n return null\n }\n }\n else if (dirPath.endsWith(\"Release\") && (name === \".deps\" || name === \"obj.target\")) {\n return null\n }\n else if (name === \"src\" && (dirPath.endsWith(\"keytar\") || dirPath.endsWith(\"keytar-prebuild\"))) {\n return null\n }\n else if (dirPath.endsWith(\"lzma-native\") && (name === \"build\" || name === \"deps\")) {\n return null\n }\n\n const filePath = dirPath + path.sep + name\n return lstat(filePath)\n .then(stat => {\n if (filter != null && !filter(filePath, stat)) {\n return null\n }\n\n if (!stat.isDirectory()) {\n metadata.set(filePath, stat)\n }\n const consumerResult = this.handleFile(filePath, dirPath, stat)\n if (consumerResult == null) {\n if (stat.isDirectory()) {\n dirs.push(name)\n return null\n }\n else {\n return filePath\n }\n }\n else {\n return consumerResult\n .then(it => {\n // asarUtil can return modified stat (symlink handling)\n if ((it == null ? stat : it).isDirectory()) {\n dirs.push(name)\n return null\n }\n else {\n return filePath\n }\n })\n }\n })\n }, CONCURRENCY)\n\n for (const child of sortedFilePaths) {\n if (child != null) {\n result.push(child)\n }\n }\n\n dirs.sort()\n for (const child of dirs) {\n queue.push(dirPath + path.sep + child)\n }\n }\n }\n return result\n }\n}"],"sourceRoot":""}