summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxetroy <troy450409405@gmail.com>2019-06-19 22:16:34 +0800
committerRyan Dahl <ry@tinyclouds.org>2019-06-19 07:16:34 -0700
commit33ffb89f5ca4dc0f671219349a084541da9db7c5 (patch)
treef425d6a898041b19840b9469d54bf3b593b4dd4c
parent57edeacaa552e97525fc5aea6b38a95d28c8f21e (diff)
installer: quote commands correctly (denoland/deno_std#510)
Original: https://github.com/denoland/deno_std/commit/4317af11d18e67dbc79b0df9839180f8e4e55613
-rw-r--r--installer/mod.ts1
-rw-r--r--installer/test.ts16
2 files changed, 9 insertions, 8 deletions
diff --git a/installer/mod.ts b/installer/mod.ts
index c0a11ac9e..f247c6fd3 100644
--- a/installer/mod.ts
+++ b/installer/mod.ts
@@ -153,6 +153,7 @@ async function generateExecutable(
filePath: string,
commands: string[]
): Promise<void> {
+ commands = commands.map((v): string => JSON.stringify(v));
// On Windows if user is using Powershell .cmd extension is need to run the
// installed module.
// Generate batch script to satisfy that.
diff --git a/installer/test.ts b/installer/test.ts
index 1767464d4..536e74c4f 100644
--- a/installer/test.ts
+++ b/installer/test.ts
@@ -71,11 +71,11 @@ installerTest(async function installBasic(): Promise<void> {
/* eslint-disable max-len */
`% This executable is generated by Deno. Please don't modify it unless you know what it means. %
@IF EXIST "%~dp0\deno.exe" (
- "%~dp0\deno.exe" run http://localhost:4500/http/file_server.ts %*
+ "%~dp0\deno.exe" "run" "http://localhost:4500/http/file_server.ts" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.TS;=;%
- deno run http://localhost:4500/http/file_server.ts %*
+ "deno" "run" "http://localhost:4500/http/file_server.ts" %*
)
`
/* eslint-enable max-len */
@@ -94,10 +94,10 @@ case \`uname\` in
esac
if [ -x "$basedir/deno" ]; then
- "$basedir/deno" run http://localhost:4500/http/file_server.ts "$@"
+ "$basedir/deno" "run" "http://localhost:4500/http/file_server.ts" "$@"
ret=$?
else
- deno run http://localhost:4500/http/file_server.ts "$@"
+ "deno" "run" "http://localhost:4500/http/file_server.ts" "$@"
ret=$?
fi
exit $ret
@@ -122,11 +122,11 @@ installerTest(async function installWithFlags(): Promise<void> {
/* eslint-disable max-len */
`% This executable is generated by Deno. Please don't modify it unless you know what it means. %
@IF EXIST "%~dp0\deno.exe" (
- "%~dp0\deno.exe" run --allow-net --allow-read http://localhost:4500/http/file_server.ts --foobar %*
+ "%~dp0\deno.exe" "run" "--allow-net" "--allow-read" "http://localhost:4500/http/file_server.ts" "--foobar" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.TS;=;%
- deno run --allow-net --allow-read http://localhost:4500/http/file_server.ts --foobar %*
+ "deno" "run" "--allow-net" "--allow-read" "http://localhost:4500/http/file_server.ts" "--foobar" %*
)
`
/* eslint-enable max-len */
@@ -145,10 +145,10 @@ case \`uname\` in
esac
if [ -x "$basedir/deno" ]; then
- "$basedir/deno" run --allow-net --allow-read http://localhost:4500/http/file_server.ts --foobar "$@"
+ "$basedir/deno" "run" "--allow-net" "--allow-read" "http://localhost:4500/http/file_server.ts" "--foobar" "$@"
ret=$?
else
- deno run --allow-net --allow-read http://localhost:4500/http/file_server.ts --foobar "$@"
+ "deno" "run" "--allow-net" "--allow-read" "http://localhost:4500/http/file_server.ts" "--foobar" "$@"
ret=$?
fi
exit $ret