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

Installer: supports windows #499

Merged
merged 28 commits into from
Jun 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
axetroy committed Jun 18, 2019
commit 6e7e1e1e34504bd633d296833fa2991557661b13
36 changes: 10 additions & 26 deletions installer/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async function genereateExecutable(
): Promise<void> {
// genereate Batch script
axetroy marked this conversation as resolved.
Show resolved Hide resolved
if (Deno.platform.os === "win") {
const cmdTemplate = `
const template = `
@IF EXIST "%~dp0\deno.exe" (
"%~dp0\deno.exe" ${commands.slice(1).join(" ")} %*
) ELSE (
Expand All @@ -167,12 +167,14 @@ async function genereateExecutable(
)
`;
const cmdFile = filePath + ".cmd";
axetroy marked this conversation as resolved.
Show resolved Hide resolved
await writeFile(cmdFile, encoder.encode(cmdTemplate));
await writeFile(cmdFile, encoder.encode(template));
await chmod(cmdFile, 0x755);
}

// generate Shell script
const template = `#/bin/sh

// generate Shell script
const shellTemplate = `#/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\,/,g')")

case \`uname\` in
*CYGWIN*) basedir=\`cygpath -w "$basedir"\`;;
Expand All @@ -187,25 +189,8 @@ else
fi
exit $ret
`;
await writeFile(filePath, encoder.encode(shellTemplate));
await chmod(filePath, 0x755);
} else {
// generate Shell script
const shellTemplate = `#/bin/sh
basedir=$(dirname "$(echo "$0")")

if [ -x "$basedir/deno" ]; then
"$basedir/deno" ${commands.slice(1).join(" ")} "$@"
ret=$?
else
${commands.join(" ")} "$@"
ret=$?
fi
exit $ret
`;
await writeFile(filePath, encoder.encode(shellTemplate));
await chmod(filePath, 0x755);
}
await writeFile(filePath, encoder.encode(template));
await chmod(filePath, 0x755);
}

export async function install(
Expand Down Expand Up @@ -261,8 +246,7 @@ export async function install(
"run",
...grantedPermissions.map(getFlagFromPermission),
moduleUrl,
...scriptArgs,
"$@"
...scriptArgs
];

await genereateExecutable(filePath, commands);
Expand Down