mirror of
https://github.com/denoland/deno.git
synced 2025-03-11 22:59:41 -04:00
installer: Print name of installed file (denoland/deno_std#492)
Original: 1679ba0b57
This commit is contained in:
parent
d00a4beec4
commit
fccfaeea3c
1 changed files with 10 additions and 8 deletions
|
@ -159,11 +159,11 @@ export async function install(
|
||||||
const installerDir = getInstallerDir();
|
const installerDir = getInstallerDir();
|
||||||
createDirIfNotExists(installerDir);
|
createDirIfNotExists(installerDir);
|
||||||
|
|
||||||
const FILE_PATH = path.join(installerDir, moduleName);
|
const filePath = path.join(installerDir, moduleName);
|
||||||
|
|
||||||
let fileInfo;
|
let fileInfo;
|
||||||
try {
|
try {
|
||||||
fileInfo = await stat(FILE_PATH);
|
fileInfo = await stat(filePath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
@ -209,9 +209,9 @@ export async function install(
|
||||||
|
|
||||||
// TODO: add windows Version
|
// TODO: add windows Version
|
||||||
const template = `#/bin/sh\n${commands.join(" ")}`;
|
const template = `#/bin/sh\n${commands.join(" ")}`;
|
||||||
await writeFile(FILE_PATH, encoder.encode(template));
|
await writeFile(filePath, encoder.encode(template));
|
||||||
|
|
||||||
const makeExecutable = run({ args: ["chmod", "+x", FILE_PATH] });
|
const makeExecutable = run({ args: ["chmod", "+x", filePath] });
|
||||||
const { code } = await makeExecutable.status();
|
const { code } = await makeExecutable.status();
|
||||||
makeExecutable.close();
|
makeExecutable.close();
|
||||||
|
|
||||||
|
@ -219,7 +219,9 @@ export async function install(
|
||||||
throw new Error("Failed to make file executable");
|
throw new Error("Failed to make file executable");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`✅ Successfully installed ${moduleName}.`);
|
console.log(`✅ Successfully installed ${moduleName}`);
|
||||||
|
console.log(filePath);
|
||||||
|
|
||||||
// TODO: add Windows version
|
// TODO: add Windows version
|
||||||
if (!checkIfExistsInPath(installerDir)) {
|
if (!checkIfExistsInPath(installerDir)) {
|
||||||
console.log("\nℹ️ Add ~/.deno/bin to PATH");
|
console.log("\nℹ️ Add ~/.deno/bin to PATH");
|
||||||
|
@ -231,17 +233,17 @@ export async function install(
|
||||||
|
|
||||||
export async function uninstall(moduleName: string): Promise<void> {
|
export async function uninstall(moduleName: string): Promise<void> {
|
||||||
const installerDir = getInstallerDir();
|
const installerDir = getInstallerDir();
|
||||||
const FILE_PATH = path.join(installerDir, moduleName);
|
const filePath = path.join(installerDir, moduleName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await stat(FILE_PATH);
|
await stat(filePath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Deno.DenoError && e.kind === Deno.ErrorKind.NotFound) {
|
if (e instanceof Deno.DenoError && e.kind === Deno.ErrorKind.NotFound) {
|
||||||
throw new Error(`ℹ️ ${moduleName} not found`);
|
throw new Error(`ℹ️ ${moduleName} not found`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await remove(FILE_PATH);
|
await remove(filePath);
|
||||||
console.log(`ℹ️ Uninstalled ${moduleName}`);
|
console.log(`ℹ️ Uninstalled ${moduleName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue