Skip to content

Commit

Permalink
use previous fs operations for copy dir, file, and symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaietta committed Jan 25, 2025
1 parent c77ab63 commit e65163c
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 37 deletions.
2 changes: 1 addition & 1 deletion packages/app-builder-lib/src/publish/updateInfoBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ async function writeOldMacInfo(
releaseDate: new Date().toISOString(),
url: computeDownloadUrl(publishConfig, packager.generateName2("zip", "mac", isGitHub), packager),
},
{ spaces: 2 }
{ prettyPrintIndent: 2 }
)

packager.info.dispatchArtifactCreated({
Expand Down
5 changes: 2 additions & 3 deletions packages/app-builder-lib/src/targets/archive.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { debug7z, exec, log } from "builder-util"
import { debug7z, exec, log, move } from "builder-util"
import { exists, unlinkIfExists, statOrNull } from "builder-util"
import { rename } from "node:fs/promises"
import * as path from "path"
import { create, CreateOptions, FileOptions } from "tar"
import { TmpDir } from "temp-file"
Expand Down Expand Up @@ -38,7 +37,7 @@ export async function tar(compression: CompressionLevel | any, format: string, o
}
await exec(lzipPath, [compression === "store" ? "-1" : "-9", "--keep" /* keep (don't delete) input files */, tarFile])
// bloody lzip creates file in the same dir where input file with postfix `.lz`, option --output doesn't work
await rename(`${tarFile}.lz`, outFile)
await move(`${tarFile}.lz`, outFile)
return
}

Expand Down
5 changes: 3 additions & 2 deletions packages/app-builder-lib/src/util/NodeModuleCopyHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { resolveFunction } from "./resolve"
import { FileCopyHelper } from "./AppFileWalker"
import { NodeModuleInfo } from "./packageDependencies"
import { realpathSync } from "fs"
import { lstatSync } from "node:fs"

const excludedFiles = new Set(
[
Expand Down Expand Up @@ -77,7 +78,7 @@ export class NodeModuleCopyHelper extends FileCopyHelper {
// our handler is async, but we should add sorted files, so, we add file to result not in the mapper, but after map
const sortedFilePaths = await BluebirdPromise.map(
childNames,
async name => {
name => {
const filePath = path.join(dirPath, name)

const forceIncluded = onNodeModuleFile != null && !!onNodeModuleFile(filePath)
Expand All @@ -87,7 +88,7 @@ export class NodeModuleCopyHelper extends FileCopyHelper {
}

// check if filematcher matches the files array as more important than the default excluded files.
const fileMatched = filter != null && filter(dirPath, await lstat(dirPath))
const fileMatched = filter != null && filter(dirPath, lstatSync(dirPath))
if (!fileMatched || !forceIncluded || !!this.packager.config.disableDefaultIgnoredFiles) {
for (const ext of nodeModuleExcludedExts) {
if (name.endsWith(ext)) {
Expand Down
Loading

0 comments on commit e65163c

Please sign in to comment.