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AAoC,eAAe,CAAC,OAAD,EAAU,QAAV,CAAnD,EAAwE,QAAxE;AACD,GAH8C,CAK/C;;;AACA,EAAA,OAAO,CAAC,IAAD,EAAe,QAAf,EAAgC,MAAhC,EAAgD,YAAhD,EAA2E;AAChF,QAAI,QAAQ,CAAC,WAAT,EAAJ,EAA4B;AAC1B;AACA;AACA;AACA,UAAI,IAAI,CAAC,QAAL,CAAc,gCAAd,CAAJ,EAAqD;AACnD,eAAO,KAAP;AACD;AACF,KAPD,MAQK;AACH;AACA,WAAK,QAAL,CAAc,GAAd,CAAkB,IAAlB,EAAwB,QAAxB;AACD;;AAED,WAAO,KAAK,UAAL,CAAgB,IAAhB,EAAsB,MAAtB,EAA8B,QAA9B,CAAP;AACD;;AArB8C,C","sourcesContent":["import { Filter, FileConsumer } from \"builder-util/out/fs\"\nimport { readlink, stat, Stats } from \"fs-extra\"\nimport { FileMatcher } from \"../fileMatcher\"\nimport { Packager } from \"../packager\"\nimport * as path from \"path\"\n\nconst nodeModulesSystemDependentSuffix = `${path.sep}node_modules`\n\nfunction addAllPatternIfNeed(matcher: FileMatcher) {\n if (!matcher.isSpecifiedAsEmptyArray && (matcher.isEmpty() || matcher.containsOnlyIgnore())) {\n matcher.prependPattern(\"**/*\")\n }\n return matcher\n}\n\nexport abstract class FileCopyHelper {\n readonly metadata = new Map<string, Stats>()\n\n protected constructor(protected readonly matcher: FileMatcher, readonly filter: Filter | null, protected readonly packager: Packager) {\n }\n\n protected handleFile(file: string, parent: string, fileStat: Stats): Promise<Stats | null> | null {\n if (!fileStat.isSymbolicLink()) {\n return null\n }\n\n return readlink(file)\n .then((linkTarget): any => {\n // http://unix.stackexchange.com/questions/105637/is-symlinks-target-relative-to-the-destinations-parent-directory-and-if-so-wh\n return this.handleSymlink(fileStat, file, parent, linkTarget)\n })\n }\n\n private handleSymlink(fileStat: Stats, file: string, parent: string, linkTarget: string): Promise<Stats> | null {\n const resolvedLinkTarget = path.resolve(parent, linkTarget)\n const link = path.relative(this.matcher.from, resolvedLinkTarget)\n if (link.startsWith(\"..\")) {\n // outside of project, linked module (https://github.com/electron-userland/electron-builder/issues/675)\n return stat(resolvedLinkTarget)\n .then(targetFileStat => {\n this.metadata.set(file, targetFileStat)\n return targetFileStat\n })\n }\n else {\n const s = (fileStat as any)\n s.relativeLink = link\n s.linkRelativeToFile = path.relative(parent, resolvedLinkTarget)\n }\n return null\n }\n}\n\nfunction createAppFilter(matcher: FileMatcher, packager: Packager): Filter | null {\n if (packager.areNodeModulesHandledExternally) {\n return matcher.isEmpty() ? null : matcher.createFilter()\n }\n\n const nodeModulesFilter: Filter = (file, fileStat) => {\n return !(fileStat.isDirectory() && file.endsWith(nodeModulesSystemDependentSuffix))\n }\n\n if (matcher.isEmpty()) {\n return nodeModulesFilter\n }\n\n const filter = matcher.createFilter()\n return (file, fileStat) => {\n if (!nodeModulesFilter(file, fileStat)) {\n return false\n }\n return filter(file, fileStat)\n }\n}\n\n/** @internal */\nexport class AppFileWalker extends FileCopyHelper implements FileConsumer {\n constructor(matcher: FileMatcher, packager: Packager) {\n super(addAllPatternIfNeed(matcher), createAppFilter(matcher, packager), packager)\n }\n\n // noinspection JSUnusedGlobalSymbols\n consume(file: string, fileStat: Stats, parent: string, siblingNames: Array<string>): any {\n if (fileStat.isDirectory()) {\n // https://github.com/electron-userland/electron-builder/issues/1539\n // but do not filter if we inside node_modules dir\n // update: solution disabled, node module resolver should support such setup\n if (file.endsWith(nodeModulesSystemDependentSuffix)) {\n return false\n }\n }\n else {\n // save memory - no need to store stat for directory\n this.metadata.set(file, fileStat)\n }\n\n return this.handleFile(file, parent, fileStat)\n }\n}"],"sourceRoot":""}
|