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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
axetroy committed Jun 18, 2019
commit e2f9bbb4a13de922ee061f6e3c776841ff7082ef
77 changes: 69 additions & 8 deletions installer/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { install, uninstall } from "./mod.ts";
import * as path from "../fs/path.ts";

let fileServer: Deno.Process;
const isWindows = Deno.platform.os === "win";

// copied from `http/file_server_test.ts`
async function startFileServer(): Promise<void> {
Expand Down Expand Up @@ -65,10 +66,40 @@ installerTest(async function installBasic(): Promise<void> {

const fileBytes = await readFile(filePath);
const fileContents = new TextDecoder().decode(fileBytes);
assertEquals(
fileContents,
"#/bin/sh\ndeno http:https://localhost:4500/http/file_server.ts $@"
);
if (isWindows) {
assertEquals(
fileContents,
`
@IF EXIST "%~dp0\deno.exe" (
"%~dp0\deno.exe" run http:https://localhost:4500/http/file_server.ts %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.TS;=;%
deno run http:https://localhost:4500/http/file_server.ts %*
)
`
);
} else {
assertEquals(
fileContents,
`#/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")

case \`uname\` in
*CYGWIN*) basedir=\`cygpath -w "$basedir"\`;;
esac

if [ -x "$basedir/deno" ]; then
"$basedir/deno" run http:https://localhost:4500/http/file_server.ts "$@"
ret=$?
else
deno run http:https://localhost:4500/http/file_server.ts "$@"
ret=$?
fi
exit $ret
`
);
}
});

installerTest(async function installWithFlags(): Promise<void> {
Expand All @@ -83,10 +114,40 @@ installerTest(async function installWithFlags(): Promise<void> {

const fileBytes = await readFile(filePath);
const fileContents = new TextDecoder().decode(fileBytes);
assertEquals(
fileContents,
"#/bin/sh\ndeno --allow-net --allow-read http:https://localhost:4500/http/file_server.ts --foobar $@"
);
if (isWindows) {
assertEquals(
fileContents,
`
@IF EXIST "%~dp0\deno.exe" (
"%~dp0\deno.exe" run --allow-net --allow-read http:https://localhost:4500/http/file_server.ts --foobar %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.TS;=;%
deno run http:https://localhost:4500/http/file_server.ts %*
)
`
);
} else {
assertEquals(
fileContents,
`#/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\\\,/,g')")

case \`uname\` in
*CYGWIN*) basedir=\`cygpath -w "$basedir"\`;;
esac

if [ -x "$basedir/deno" ]; then
"$basedir/deno" run --allow-net --allow-read http:https://localhost:4500/http/file_server.ts --foobar "$@"
ret=$?
else
deno run --allow-net --allow-read http:https://localhost:4500/http/file_server.ts --foobar "$@"
ret=$?
fi
exit $ret
`
);
}
});

installerTest(async function uninstallBasic(): Promise<void> {
Expand Down