Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fix for path error when setup is used #590

Merged
merged 4 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 3 additions & 57 deletions javascript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 48 additions & 42 deletions javascript/packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,50 +63,56 @@ let network: Network | undefined;

// Download the binaries
const downloadBinaries = async (binaries: string[]): Promise<void> => {
console.log(`${decorators.yellow("\nStart download...\n")}`);
const promises = [];
let count = 0;
for (let binary of binaries) {
promises.push(
new Promise<void>(async (resolve) => {
const { url, name } = options[binary];
const { data, headers } = await axios({
url,
method: "GET",
responseType: "stream",
});
const totalLength = headers["content-length"];

const progressBar = new progress(
"-> downloading [:bar] :percent :etas",
{
width: 40,
complete: "=",
incomplete: " ",
renderThrottle: 1,
total: parseInt(totalLength),
},
);

const writer = fs.createWriteStream(path.resolve(__dirname, name));

data.on("data", (chunk: any) => progressBar.tick(chunk.length));
data.pipe(writer);
data.on("end", () => {
console.log(decorators.yellow(`Binary "${name}" downloaded`));
// Add permissions to the binary
console.log(decorators.cyan(`Giving permissions to "${name}"`));
fs.chmodSync(path.resolve(__dirname, name), 0o755);
resolve();
});
}),
try {
console.log(`${decorators.yellow("\nStart download...\n")}`);
const promises = [];
let count = 0;
for (let binary of binaries) {
promises.push(
new Promise<void>(async (resolve) => {
const { url, name } = options[binary];
const { data, headers } = await axios({
url,
method: "GET",
responseType: "stream",
});
const totalLength = headers["content-length"];

const progressBar = new progress(
"-> downloading [:bar] :percent :etas",
{
width: 40,
complete: "=",
incomplete: " ",
renderThrottle: 1,
total: parseInt(totalLength),
},
);

const writer = fs.createWriteStream(path.resolve(name));

data.on("data", (chunk: any) => progressBar.tick(chunk.length));
data.pipe(writer);
data.on("end", () => {
console.log(decorators.yellow(`Binary "${name}" downloaded`));
// Add permissions to the binary
console.log(decorators.cyan(`Giving permissions to "${name}"`));
fs.chmodSync(path.resolve(name), 0o755);
resolve();
});
}),
);
}
await Promise.all(promises);
console.log(
decorators.cyan(
`Please add the dir to your $PATH by running the command:\n`,
),
decorators.blue(`export PATH=${__dirname}:$PATH`),
);
} catch (err) {
console.log("Unexpected error: ", err);
}
await Promise.all(promises);
console.log(
decorators.cyan(`Please add the dir to your $PATH by running the command:`),
decorators.blue(`export PATH=${__dirname}:$PATH`),
);
};

// Retrieve the latest release for polkadot
Expand Down