Skip to content

Commit

Permalink
change deno --types to deno types
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju committed Apr 20, 2019
1 parent 9625237 commit 5d61aea
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 32 deletions.
23 changes: 3 additions & 20 deletions cli/flags.rs
Expand Up @@ -21,7 +21,6 @@ pub struct DenoFlags {
pub allow_run: bool,
pub allow_high_precision: bool,
pub no_prompts: bool,
pub types: bool,
pub prefetch: bool,
}

Expand Down Expand Up @@ -68,9 +67,6 @@ impl<'a> From<ArgMatches<'a>> for DenoFlags {
if matches.is_present("no-prompt") {
flags.no_prompts = true;
}
if matches.is_present("types") {
flags.types = true;
}
if matches.is_present("prefetch") {
flags.prefetch = true;
}
Expand Down Expand Up @@ -149,14 +145,13 @@ 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("types")
.long("types")
.help("Print runtime TypeScript declarations"),
).arg(
Arg::with_name("prefetch")
.long("prefetch")
.help("Prefetch the dependencies"),
).subcommand(
SubCommand::with_name("types")
.about("Print runtime TypeScript declarations"),
).subcommand(
SubCommand::with_name("info")
.setting(AppSettings::DisableVersion)
Expand Down Expand Up @@ -272,18 +267,6 @@ mod tests {
);
}

#[test]
fn test_set_flags_5() {
let flags = flags_from_vec(svec!["deno", "--types"]);
assert_eq!(
flags,
DenoFlags {
types: true,
..DenoFlags::default()
}
)
}

#[test]
fn test_set_flags_6() {
let flags =
Expand Down
17 changes: 17 additions & 0 deletions cli/main.rs
Expand Up @@ -43,6 +43,7 @@ use futures::lazy;
use futures::Future;
use log::{LevelFilter, Metadata, Record};
use std::env;
use std::path::Path;

static LOGGER: Logger = Logger;

Expand Down Expand Up @@ -138,6 +139,19 @@ fn get_worker_and_state(
(worker, state)
}

fn types_command() {
let p = Path::new(concat!(
env!("GN_OUT_DIR"),
"/gen/cli/lib/lib.deno_runtime.d.ts"
));
let content_bytes = std::fs::read(p).unwrap();
let content = std::str::from_utf8(&content_bytes[..]).unwrap();

println!("{}", content);

std::process::exit(0);
}

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

Expand Down Expand Up @@ -260,6 +274,9 @@ fn main() {

let mut rest_argv: Vec<String> = vec!["deno".to_string()];
match matches.subcommand() {
("types", Some(_)) => {
types_command();
}
("eval", Some(info_match)) => {
let code: &str = info_match.value_of("code").unwrap();
rest_argv.extend(vec![code.to_string()]);
Expand Down
1 change: 0 additions & 1 deletion cli/ops.rs
Expand Up @@ -321,7 +321,6 @@ fn op_start(
argv: Some(argv_off),
main_module,
debug_flag: state.flags.log_debug,
types_flag: state.flags.types,
version_flag: state.flags.version,
v8_version: Some(v8_version_off),
deno_version: Some(deno_version_off),
Expand Down
10 changes: 0 additions & 10 deletions js/main.ts
Expand Up @@ -15,9 +15,6 @@ import { setLocation } from "./location";
// builtin modules
import * as deno from "./deno";

// TODO(kitsonk) remove with `--types` below
import libDts from "gen/cli/lib/lib.deno_runtime.d.ts!string";

export default function denoMain(name?: string): void {
const startResMsg = os.start(name);

Expand All @@ -31,13 +28,6 @@ export default function denoMain(name?: string): void {
os.exit(0);
}

// handle `--types`
// TODO(kitsonk) move to Rust fetching from compiler
if (startResMsg.typesFlag()) {
console.log(libDts);
os.exit(0);
}

const mainModule = startResMsg.mainModule();
if (mainModule) {
assert(mainModule.length > 0);
Expand Down
2 changes: 1 addition & 1 deletion tools/docs.py
Expand Up @@ -11,7 +11,7 @@
# Builds into target/doc
run(["cargo", "doc", "--all", "--no-deps", "-vv"])

# 'deno --types' is stored in target/debug/gen/cli/lib/lib.deno_runtime.d.ts
# 'deno types' is stored in target/debug/gen/cli/lib/lib.deno_runtime.d.ts
# We want to run typedoc on that declaration file only.
os.chdir(os.path.join(target_path, "debug/gen/cli/lib/"))

Expand Down

0 comments on commit 5d61aea

Please sign in to comment.