Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Oct 19, 2023
1 parent d1d2733 commit f41b292
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion fixtures/npm-integration-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const { ConsoleLogger } = require("libpkgx/plumbing/install")

console.log(ConfigDefault(), ConsoleLogger())

run("ls -la")
run("ls -h")
58 changes: 29 additions & 29 deletions src/plumbing/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,35 +69,35 @@ Deno.test("install", async runner => {
})
})

// await runner.step("install locks", async () => {

// const conf = useTestConfig({ CI: "1" })

// /// download() will use the cached version and not do http
// srcroot.join("fixtures/foo.com-5.43.0.tgz").cp({ to:
// conf.cache.mkdir('p').join(`foo.com-5.43.0+${platform}+${arch}.tar.gz`)
// })

// let unlocked_once = false
// const logger: Logger = {
// downloading: () => assertFalse(unlocked_once),
// locking: () => {},
// installed: () => {},
// installing: () => assertFalse(unlocked_once),
// unlocking: () => unlocked_once = true
// }

// const installer1 = install(pkg, logger)
// const installer2 = install(pkg, logger)

// const [install1, install2] = await Promise.all([installer1, installer2])

// for (const installation of [install1, install2]) {
// assertEquals(installation.pkg.project, pkg.project)
// assertEquals(installation.pkg.version, pkg.version)
// assertEquals(installation.path, conf.prefix.join(pkg.project, `v${pkg.version}`))
// }
// })
await runner.step("install locks", async () => {

const conf = useTestConfig({ CI: "1" })

/// download() will use the cached version and not do http
srcroot.join("fixtures/foo.com-5.43.0.tgz").cp({ to:
conf.cache.mkdir('p').join(`foo.com-5.43.0+${platform}+${arch}.tar.gz`)
})

let unlocked_once = false
const logger: Logger = {
downloading: () => assertFalse(unlocked_once),
locking: () => {},
installed: () => {},
installing: () => assertFalse(unlocked_once),
unlocking: () => unlocked_once = true
}

const installer1 = install(pkg, logger)
const installer2 = install(pkg, logger)

const [install1, install2] = await Promise.all([installer1, installer2])

for (const installation of [install1, install2]) {
assertEquals(installation.pkg.project, pkg.project)
assertEquals(installation.pkg.version, pkg.version)
assertEquals(installation.path, conf.prefix.join(pkg.project, `v${pkg.version}`))
}
})

} finally {
fetch_stub.restore()
Expand Down
4 changes: 3 additions & 1 deletion src/plumbing/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export default async function install(pkg: Package, logger?: Logger): Promise<In

logger?.downloading?.({pkg})

const PATH = Deno.build.os == 'windows' ? "C:\\windows\\system32" : "/usr/bin:/bin"

const tmpdir = Path.mktemp({
//TODO dir should not be here ofc
dir: PKGX_DIR.join(".local/tmp").join(pkg.project),
Expand All @@ -52,7 +54,7 @@ export default async function install(pkg: Package, logger?: Logger): Promise<In
stdin: 'piped', stdout: "inherit", stderr: "inherit",
cwd: tmpdir.string,
/// hard coding path to ensure we don’t deadlock trying to use ourselves to untar ourselves
env: { PATH: "/usr/bin:/bin" }
env: { PATH }
})
const hasher = createHash("sha256")
const remote_SHA_promise = remote_SHA(new URL(`${url}.sha256sum`))
Expand Down
3 changes: 1 addition & 2 deletions src/utils/flock.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ async function flock(path: Path) {
//NOTE this absolutely must be done before v1 since it means our npm pkg and deno pkgs are not lock compatible
// NOTES I tried 😔 and couldn’t figure it out. Damn Win32 bests me again.

return await lockfile.lock(path.string)

return await lockfile.lock(path.string, {retries: 100})
}
}

Expand Down

0 comments on commit f41b292

Please sign in to comment.