mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 23:34:47 -05:00
Add deno.argv.
This commit is contained in:
parent
fde96a8e43
commit
722c7e4a1b
2 changed files with 6 additions and 3 deletions
|
@ -2,3 +2,4 @@
|
||||||
// Public deno module.
|
// Public deno module.
|
||||||
export { exit, readFileSync, writeFileSync } from "./os";
|
export { exit, readFileSync, writeFileSync } from "./os";
|
||||||
export { libdeno } from "./libdeno";
|
export { libdeno } from "./libdeno";
|
||||||
|
export const argv: string[] = [];
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { DenoCompiler } from "./compiler";
|
||||||
import { libdeno } from "./libdeno";
|
import { libdeno } from "./libdeno";
|
||||||
import * as timers from "./timers";
|
import * as timers from "./timers";
|
||||||
import { onFetchRes } from "./fetch";
|
import { onFetchRes } from "./fetch";
|
||||||
|
import { argv } from "./deno";
|
||||||
|
|
||||||
function startMsg(cmdId: number): Uint8Array {
|
function startMsg(cmdId: number): Uint8Array {
|
||||||
const builder = new flatbuffers.Builder();
|
const builder = new flatbuffers.Builder();
|
||||||
|
@ -85,13 +86,14 @@ export default function denoMain() {
|
||||||
const cwd = startResMsg.cwd();
|
const cwd = startResMsg.cwd();
|
||||||
log("cwd", cwd);
|
log("cwd", cwd);
|
||||||
|
|
||||||
const argv: string[] = [];
|
// TODO handle shebang.
|
||||||
for (let i = 0; i < startResMsg.argvLength(); i++) {
|
for (let i = 1; i < startResMsg.argvLength(); i++) {
|
||||||
argv.push(startResMsg.argv(i));
|
argv.push(startResMsg.argv(i));
|
||||||
}
|
}
|
||||||
log("argv", argv);
|
log("argv", argv);
|
||||||
|
Object.freeze(argv);
|
||||||
|
|
||||||
const inputFn = argv[1];
|
const inputFn = argv[0];
|
||||||
if (!inputFn) {
|
if (!inputFn) {
|
||||||
console.log("No input script specified.");
|
console.log("No input script specified.");
|
||||||
os.exit(1);
|
os.exit(1);
|
||||||
|
|
Loading…
Reference in a new issue