Skip to content
Permalink
Browse files

change deno --prefetch to deno prefetch

  • Loading branch information...
bartlomieju committed Apr 20, 2019
1 parent b2e877e commit 691aea7411be3a86b8d99d0ab0fe8920a80cc142
Showing with 24 additions and 17 deletions.
  1. +8 −10 cli/flags.rs
  2. +15 −6 cli/main.rs
  3. +1 −1 tools/prefetch_test.py
@@ -21,7 +21,6 @@ pub struct DenoFlags {
pub allow_run: bool,
pub allow_high_precision: bool,
pub no_prompts: bool,
pub prefetch: bool,
}

impl<'a> From<ArgMatches<'a>> for DenoFlags {
@@ -67,9 +66,6 @@ impl<'a> From<ArgMatches<'a>> for DenoFlags {
if matches.is_present("no-prompt") {
flags.no_prompts = true;
}
if matches.is_present("prefetch") {
flags.prefetch = true;
}

flags
}
@@ -145,12 +141,14 @@ pub fn create_cli_app<'a, 'b>() -> App<'a, 'b> {
.takes_value(true)
.require_equals(true)
.help("Set V8 command line options"),
).arg(
Arg::with_name("prefetch")
.long("prefetch")
.help("Prefetch the dependencies"),
).subcommand(
SubCommand::with_name("prefetch")
.setting(AppSettings::DisableVersion)
.about("Prefetch the dependencies")
.arg(Arg::with_name("file").takes_value(true).required(true)),
).subcommand(
SubCommand::with_name("types")
.setting(AppSettings::DisableVersion)
.about("Print runtime TypeScript declarations"),
).subcommand(
SubCommand::with_name("info")
@@ -174,8 +172,8 @@ pub fn create_cli_app<'a, 'b>() -> App<'a, 'b> {
),
).subcommand(
// this is a fake subcommand - it's used in conjunction with
// AppSettings:AllowExternalSubcommand to treat it as an
// entry point script
// AppSettings:AllowExternalSubcommand to make it behave like 'run'
// subcommand
SubCommand::with_name("<script>").about("Script to run"),
)
}
@@ -152,7 +152,11 @@ fn types_command() {
std::process::exit(0);
}

fn info_command(flags: DenoFlags, argv: Vec<String>) {
fn prefetch_or_info_command(
flags: DenoFlags,
argv: Vec<String>,
print_info: bool,
) {
let (mut worker, state) = get_worker_and_state(flags, argv);

let main_module = state.main_module().unwrap();
@@ -166,7 +170,9 @@ fn info_command(flags: DenoFlags, argv: Vec<String>) {
worker
.execute_mod_async(&main_url, true)
.and_then(move |worker| {
print_file_info(&worker, &main_module);
if print_info {
print_file_info(&worker, &main_module);
}
worker.then(|result| {
js_check(result);
Ok(())
@@ -221,8 +227,6 @@ fn run_repl(flags: DenoFlags, argv: Vec<String>) {
}

fn run_script(flags: DenoFlags, argv: Vec<String>) {
let should_prefetch = flags.prefetch;

let (mut worker, state) = get_worker_and_state(flags, argv);

let main_module = state.main_module().unwrap();
@@ -235,7 +239,7 @@ fn run_script(flags: DenoFlags, argv: Vec<String>) {
let main_url = root_specifier_to_url(&main_module).unwrap();

worker
.execute_mod_async(&main_url, should_prefetch)
.execute_mod_async(&main_url, false)
.and_then(move |worker| {
worker.then(|result| {
js_check(result);
@@ -285,7 +289,12 @@ fn main() {
("info", Some(info_match)) => {
let file: &str = info_match.value_of("file").unwrap();
rest_argv.extend(vec![file.to_string()]);
info_command(flags, rest_argv);
prefetch_or_info_command(flags, rest_argv, true);
}
("prefetch", Some(info_match)) => {
let file: &str = info_match.value_of("file").unwrap();
rest_argv.extend(vec![file.to_string()]);
prefetch_or_info_command(flags, rest_argv, false);
}
("fmt", Some(fmt_match)) => {
let files: Vec<String> = fmt_match
@@ -13,7 +13,7 @@ def prefetch_test(deno_exe):
deno_dir = mkdtemp()
try:
t = os.path.join(tests_path, "006_url_imports.ts")
output = run_output([deno_exe, "--prefetch", t],
output = run_output([deno_exe, "prefetch", t],
merge_env={"DENO_DIR": deno_dir})
assert output == ""
# Check that we actually did the prefetch.

0 comments on commit 691aea7

Please sign in to comment.
You can’t perform that action at this time.