This repository has been archived by the owner on Aug 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a23cab
commit b88de95
Showing
5 changed files
with
47 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const { Binary } = require("binary-install"); | ||
const os = require("os"); | ||
const { join } = require("path"); | ||
|
||
const getPlatform = () => { | ||
const type = os.type(); | ||
const arch = os.arch(); | ||
|
||
if (type === "Windows_NT" && arch === "x64") { | ||
return "x86_64-pc-windows-msvc"; | ||
} | ||
if (type === "Linux" && arch === "x64") { | ||
return "x86_64-unknown-linux-musl"; | ||
} | ||
if (type === "Darwin" && arch === "x64") { | ||
return "x86_64-apple-darwin"; | ||
} | ||
|
||
throw new Error(`Unsupported platform: ${type} ${arch}`); | ||
}; | ||
|
||
const getBinary = () => { | ||
const platform = getPlatform(); | ||
const version = require("./package.json").version; | ||
const url = `https://workers.cloudflare.com/get-npm-wrangler-binary/${version}/${platform}`; | ||
const installDirectory = join(os.homedir(), ".wrangler"); | ||
return new Binary(url, { name: "wrangler", installDirectory }); | ||
}; | ||
|
||
const run = () => { | ||
const binary = getBinary(); | ||
binary.run(); | ||
}; | ||
|
||
const install = () => { | ||
const binary = getBinary(); | ||
binary.install(); | ||
}; | ||
|
||
module.exports = { | ||
install, | ||
run | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
const { join } = require("path"); | ||
const { spawnSync } = require("child_process"); | ||
const { homedir } = require("os"); | ||
|
||
const cwd = join(homedir(), ".wrangler"); | ||
const bin = join(cwd, "out", "wrangler"); | ||
const [, , ...args] = process.argv; | ||
|
||
const opts = { | ||
cwd: process.cwd(), | ||
stdio: "inherit" | ||
}; | ||
|
||
const result = spawnSync(bin, args, opts); | ||
|
||
if (result.error) { | ||
console.error(result.error); | ||
process.exit(1); | ||
} | ||
|
||
process.exit(result.status); | ||
const { run } = require("./binary"); | ||
run() |