mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
Unstable methods should not appear in runtime or d.ts (#4957)
Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
This commit is contained in:
parent
4993a6504b
commit
80e2211141
35 changed files with 1659 additions and 1350 deletions
|
@ -95,6 +95,10 @@ fn main() {
|
|||
"lib.deno.ns.d.ts".to_string(),
|
||||
c.join("js/lib.deno.ns.d.ts"),
|
||||
);
|
||||
custom_libs.insert(
|
||||
"lib.deno.unstable.d.ts".to_string(),
|
||||
c.join("js/lib.deno.unstable.d.ts"),
|
||||
);
|
||||
runtime_isolate.register_op(
|
||||
"op_fetch_asset",
|
||||
deno_typescript::op_fetch_asset(custom_libs),
|
||||
|
|
|
@ -175,6 +175,7 @@ fn req(
|
|||
out_file: Option<PathBuf>,
|
||||
target: &str,
|
||||
bundle: bool,
|
||||
unstable: bool,
|
||||
) -> Buf {
|
||||
let j = match (compiler_config.path, compiler_config.content) {
|
||||
(Some(config_path), Some(config_data)) => json!({
|
||||
|
@ -183,6 +184,7 @@ fn req(
|
|||
"rootNames": root_names,
|
||||
"outFile": out_file,
|
||||
"bundle": bundle,
|
||||
"unstable": unstable,
|
||||
"configPath": config_path,
|
||||
"config": str::from_utf8(&config_data).unwrap(),
|
||||
}),
|
||||
|
@ -192,6 +194,7 @@ fn req(
|
|||
"rootNames": root_names,
|
||||
"outFile": out_file,
|
||||
"bundle": bundle,
|
||||
"unstable": unstable,
|
||||
}),
|
||||
};
|
||||
|
||||
|
@ -290,6 +293,7 @@ impl TsCompiler {
|
|||
out_file,
|
||||
"main",
|
||||
true,
|
||||
global_state.flags.unstable,
|
||||
);
|
||||
|
||||
let msg = execute_in_thread(global_state.clone(), req_msg).await?;
|
||||
|
@ -371,6 +375,7 @@ impl TsCompiler {
|
|||
None,
|
||||
target,
|
||||
false,
|
||||
global_state.flags.unstable,
|
||||
);
|
||||
|
||||
let ts_compiler = self.clone();
|
||||
|
@ -655,6 +660,7 @@ pub fn runtime_compile<S: BuildHasher>(
|
|||
"sources": sources,
|
||||
"options": options,
|
||||
"bundle": bundle,
|
||||
"unstable": global_state.flags.unstable,
|
||||
})
|
||||
.to_string()
|
||||
.into_boxed_str()
|
||||
|
|
152
cli/flags.rs
152
cli/flags.rs
|
@ -90,34 +90,33 @@ pub struct Flags {
|
|||
pub argv: Vec<String>,
|
||||
pub subcommand: DenoSubcommand,
|
||||
|
||||
pub log_level: Option<Level>,
|
||||
pub version: bool,
|
||||
pub reload: bool,
|
||||
pub allow_env: bool,
|
||||
pub allow_hrtime: bool,
|
||||
pub allow_net: bool,
|
||||
pub allow_plugin: bool,
|
||||
pub allow_read: bool,
|
||||
pub allow_run: bool,
|
||||
pub allow_write: bool,
|
||||
pub cache_blacklist: Vec<String>,
|
||||
pub ca_file: Option<String>,
|
||||
pub cached_only: bool,
|
||||
pub config_path: Option<String>,
|
||||
pub import_map_path: Option<String>,
|
||||
pub allow_read: bool,
|
||||
pub read_whitelist: Vec<PathBuf>,
|
||||
pub cache_blacklist: Vec<String>,
|
||||
pub allow_write: bool,
|
||||
pub write_whitelist: Vec<PathBuf>,
|
||||
pub allow_net: bool,
|
||||
pub net_whitelist: Vec<String>,
|
||||
pub allow_env: bool,
|
||||
pub allow_run: bool,
|
||||
pub allow_plugin: bool,
|
||||
pub allow_hrtime: bool,
|
||||
pub no_prompts: bool,
|
||||
pub no_remote: bool,
|
||||
pub cached_only: bool,
|
||||
pub inspect: Option<SocketAddr>,
|
||||
pub inspect_brk: Option<SocketAddr>,
|
||||
pub seed: Option<u64>,
|
||||
pub v8_flags: Option<Vec<String>>,
|
||||
pub unstable: bool,
|
||||
|
||||
pub lock: Option<String>,
|
||||
pub lock_write: bool,
|
||||
pub ca_file: Option<String>,
|
||||
pub log_level: Option<Level>,
|
||||
pub net_whitelist: Vec<String>,
|
||||
pub no_prompts: bool,
|
||||
pub no_remote: bool,
|
||||
pub read_whitelist: Vec<PathBuf>,
|
||||
pub reload: bool,
|
||||
pub seed: Option<u64>,
|
||||
pub unstable: bool,
|
||||
pub v8_flags: Option<Vec<String>>,
|
||||
pub version: bool,
|
||||
pub write_whitelist: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
fn join_paths(whitelist: &[PathBuf], d: &str) -> String {
|
||||
|
@ -330,7 +329,8 @@ If the flag is set, restrict these messages to errors.",
|
|||
.after_help(ENV_VARIABLES_HELP)
|
||||
}
|
||||
|
||||
fn types_parse(flags: &mut Flags, _matches: &clap::ArgMatches) {
|
||||
fn types_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
||||
unstable_arg_parse(flags, matches);
|
||||
flags.subcommand = DenoSubcommand::Types;
|
||||
}
|
||||
|
||||
|
@ -348,6 +348,7 @@ fn fmt_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
fn install_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
||||
permission_args_parse(flags, matches);
|
||||
ca_file_arg_parse(flags, matches);
|
||||
unstable_arg_parse(flags, matches);
|
||||
|
||||
let root = if matches.is_present("root") {
|
||||
let install_root = matches.value_of("root").unwrap();
|
||||
|
@ -416,6 +417,7 @@ fn repl_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
v8_flags_arg_parse(flags, matches);
|
||||
ca_file_arg_parse(flags, matches);
|
||||
inspect_arg_parse(flags, matches);
|
||||
unstable_arg_parse(flags, matches);
|
||||
flags.subcommand = DenoSubcommand::Repl;
|
||||
flags.allow_net = true;
|
||||
flags.allow_env = true;
|
||||
|
@ -430,6 +432,7 @@ fn eval_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
v8_flags_arg_parse(flags, matches);
|
||||
ca_file_arg_parse(flags, matches);
|
||||
inspect_arg_parse(flags, matches);
|
||||
unstable_arg_parse(flags, matches);
|
||||
flags.allow_net = true;
|
||||
flags.allow_env = true;
|
||||
flags.allow_run = true;
|
||||
|
@ -447,6 +450,7 @@ fn eval_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
|
||||
fn info_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
||||
ca_file_arg_parse(flags, matches);
|
||||
unstable_arg_parse(flags, matches);
|
||||
|
||||
flags.subcommand = DenoSubcommand::Info {
|
||||
file: matches.value_of("file").map(|f| f.to_string()),
|
||||
|
@ -576,6 +580,8 @@ fn upgrade_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
|
||||
fn doc_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
||||
reload_arg_parse(flags, matches);
|
||||
unstable_arg_parse(flags, matches);
|
||||
|
||||
let source_file = matches.value_of("source_file").map(String::from);
|
||||
let json = matches.is_present("json");
|
||||
let filter = matches.value_of("filter").map(String::from);
|
||||
|
@ -588,6 +594,7 @@ fn doc_parse(flags: &mut Flags, matches: &clap::ArgMatches) {
|
|||
|
||||
fn types_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||
SubCommand::with_name("types")
|
||||
.arg(unstable_arg())
|
||||
.about("Print runtime TypeScript declarations")
|
||||
.long_about(
|
||||
"Print runtime TypeScript declarations.
|
||||
|
@ -628,6 +635,7 @@ fn repl_subcommand<'a, 'b>() -> App<'a, 'b> {
|
|||
.about("Read Eval Print Loop")
|
||||
.arg(v8_flags_arg())
|
||||
.arg(ca_file_arg())
|
||||
.arg(unstable_arg())
|
||||
}
|
||||
|
||||
fn install_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||
|
@ -656,6 +664,7 @@ fn install_subcommand<'a, 'b>() -> App<'a, 'b> {
|
|||
.allow_hyphen_values(true)
|
||||
)
|
||||
.arg(ca_file_arg())
|
||||
.arg(unstable_arg())
|
||||
.about("Install script as an executable")
|
||||
.long_about(
|
||||
"Installs a script as an executable in the installation root's bin directory.
|
||||
|
@ -713,6 +722,7 @@ fn completions_subcommand<'a, 'b>() -> App<'a, 'b> {
|
|||
fn eval_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||
inspect_args(SubCommand::with_name("eval"))
|
||||
.arg(ca_file_arg())
|
||||
.arg(unstable_arg())
|
||||
.about("Eval script")
|
||||
.long_about(
|
||||
"Evaluate JavaScript from the command line.
|
||||
|
@ -760,6 +770,7 @@ TypeScript compiler cache: Subdirectory containing TS compiler output.",
|
|||
)
|
||||
.arg(Arg::with_name("file").takes_value(true).required(false))
|
||||
.arg(ca_file_arg())
|
||||
.arg(unstable_arg())
|
||||
}
|
||||
|
||||
fn cache_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||
|
@ -816,6 +827,7 @@ and is used to replace the current executable.",
|
|||
|
||||
fn doc_subcommand<'a, 'b>() -> App<'a, 'b> {
|
||||
SubCommand::with_name("doc")
|
||||
.arg(unstable_arg())
|
||||
.about("Show documentation for a module")
|
||||
.long_about(
|
||||
"Show documentation for a module.
|
||||
|
@ -1647,6 +1659,19 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn types_unstable() {
|
||||
let r = flags_from_vec_safe(svec!["deno", "types", "--unstable"]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
unstable: true,
|
||||
subcommand: DenoSubcommand::Types,
|
||||
..Flags::default()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cache() {
|
||||
let r = flags_from_vec_safe(svec!["deno", "cache", "script.ts"]);
|
||||
|
@ -1661,6 +1686,22 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cache_unstable() {
|
||||
let r =
|
||||
flags_from_vec_safe(svec!["deno", "cache", "--unstable", "script.ts"]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
unstable: true,
|
||||
subcommand: DenoSubcommand::Cache {
|
||||
files: svec!["script.ts"],
|
||||
},
|
||||
..Flags::default()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn info() {
|
||||
let r = flags_from_vec_safe(svec!["deno", "info", "script.ts"]);
|
||||
|
@ -1728,6 +1769,34 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eval_unstable() {
|
||||
let r = flags_from_vec_safe(svec![
|
||||
"deno",
|
||||
"eval",
|
||||
"--unstable",
|
||||
"'console.log(\"hello\")'"
|
||||
]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
unstable: true,
|
||||
subcommand: DenoSubcommand::Eval {
|
||||
code: "'console.log(\"hello\")'".to_string(),
|
||||
as_typescript: false,
|
||||
},
|
||||
allow_net: true,
|
||||
allow_env: true,
|
||||
allow_run: true,
|
||||
allow_read: true,
|
||||
allow_write: true,
|
||||
allow_plugin: true,
|
||||
allow_hrtime: true,
|
||||
..Flags::default()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eval_typescript() {
|
||||
let r = flags_from_vec_safe(svec![
|
||||
|
@ -1798,6 +1867,26 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repl_unstable() {
|
||||
let r = flags_from_vec_safe(svec!["deno", "repl", "--unstable"]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
unstable: true,
|
||||
subcommand: DenoSubcommand::Repl,
|
||||
allow_net: true,
|
||||
allow_env: true,
|
||||
allow_run: true,
|
||||
allow_read: true,
|
||||
allow_write: true,
|
||||
allow_plugin: true,
|
||||
allow_hrtime: true,
|
||||
..Flags::default()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn allow_read_whitelist() {
|
||||
use tempfile::TempDir;
|
||||
|
@ -1917,6 +2006,23 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bundle_unstable() {
|
||||
let r =
|
||||
flags_from_vec_safe(svec!["deno", "bundle", "--unstable", "source.ts"]);
|
||||
assert_eq!(
|
||||
r.unwrap(),
|
||||
Flags {
|
||||
unstable: true,
|
||||
subcommand: DenoSubcommand::Bundle {
|
||||
source_file: "source.ts".to_string(),
|
||||
out_file: None,
|
||||
},
|
||||
..Flags::default()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bundle_with_output() {
|
||||
let r =
|
||||
|
|
|
@ -20,6 +20,7 @@ pub static DENO_NS_LIB: &str = include_str!("js/lib.deno.ns.d.ts");
|
|||
pub static SHARED_GLOBALS_LIB: &str =
|
||||
include_str!("js/lib.deno.shared_globals.d.ts");
|
||||
pub static WINDOW_LIB: &str = include_str!("js/lib.deno.window.d.ts");
|
||||
pub static UNSTABLE_NS_LIB: &str = include_str!("js/lib.deno.unstable.d.ts");
|
||||
|
||||
#[test]
|
||||
fn cli_snapshot() {
|
||||
|
|
|
@ -51,7 +51,8 @@ interface CompilerRequestCompile {
|
|||
// options: ts.CompilerOptions;
|
||||
configPath?: string;
|
||||
config?: string;
|
||||
bundle?: boolean;
|
||||
unstable: boolean;
|
||||
bundle: boolean;
|
||||
outFile?: string;
|
||||
}
|
||||
|
||||
|
@ -60,6 +61,7 @@ interface CompilerRequestRuntimeCompile {
|
|||
target: CompilerHostTarget;
|
||||
rootName: string;
|
||||
sources?: Record<string, string>;
|
||||
unstable?: boolean;
|
||||
bundle?: boolean;
|
||||
options?: string;
|
||||
}
|
||||
|
@ -90,7 +92,15 @@ type RuntimeBundleResult = [undefined | DiagnosticItem[], string];
|
|||
async function compile(
|
||||
request: CompilerRequestCompile
|
||||
): Promise<CompileResult> {
|
||||
const { bundle, config, configPath, outFile, rootNames, target } = request;
|
||||
const {
|
||||
bundle,
|
||||
config,
|
||||
configPath,
|
||||
outFile,
|
||||
rootNames,
|
||||
target,
|
||||
unstable,
|
||||
} = request;
|
||||
util.log(">>> compile start", {
|
||||
rootNames,
|
||||
type: CompilerRequestType[request.type],
|
||||
|
@ -116,6 +126,7 @@ async function compile(
|
|||
bundle,
|
||||
target,
|
||||
writeFile,
|
||||
unstable,
|
||||
}));
|
||||
let diagnostics: readonly ts.Diagnostic[] | undefined;
|
||||
|
||||
|
@ -185,7 +196,7 @@ async function compile(
|
|||
async function runtimeCompile(
|
||||
request: CompilerRequestRuntimeCompile
|
||||
): Promise<RuntimeCompileResult | RuntimeBundleResult> {
|
||||
const { rootName, sources, options, bundle, target } = request;
|
||||
const { bundle, options, rootName, sources, target, unstable } = request;
|
||||
|
||||
util.log(">>> runtime compile start", {
|
||||
rootName,
|
||||
|
@ -259,6 +270,14 @@ async function runtimeCompile(
|
|||
if (convertedOptions) {
|
||||
compilerOptions.push(convertedOptions);
|
||||
}
|
||||
if (unstable) {
|
||||
compilerOptions.push({
|
||||
lib: [
|
||||
"deno.unstable",
|
||||
...((convertedOptions && convertedOptions.lib) || ["deno.window"]),
|
||||
],
|
||||
});
|
||||
}
|
||||
if (bundle) {
|
||||
compilerOptions.push(defaultBundlerOptions);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ ts.libMap.set("deno.ns", "lib.deno.ns.d.ts");
|
|||
ts.libMap.set("deno.window", "lib.deno.window.d.ts");
|
||||
ts.libMap.set("deno.worker", "lib.deno.worker.d.ts");
|
||||
ts.libMap.set("deno.shared_globals", "lib.deno.shared_globals.d.ts");
|
||||
ts.libMap.set("deno.unstable", "lib.deno.unstable.d.ts");
|
||||
|
||||
// this pre-populates the cache at snapshot time of our library files, so they
|
||||
// are available in the future when needed.
|
||||
|
@ -30,6 +31,7 @@ host.getSourceFile(
|
|||
`${ASSETS}/lib.deno.shared_globals.d.ts`,
|
||||
ts.ScriptTarget.ESNext
|
||||
);
|
||||
host.getSourceFile(`${ASSETS}/lib.deno.unstable.d.ts`, ts.ScriptTarget.ESNext);
|
||||
|
||||
export const TS_SNAPSHOT_PROGRAM = ts.createProgram({
|
||||
rootNames: [`${ASSETS}/bootstrap.ts`],
|
||||
|
|
|
@ -14,9 +14,8 @@ export enum CompilerHostTarget {
|
|||
|
||||
export interface CompilerHostOptions {
|
||||
bundle?: boolean;
|
||||
|
||||
target: CompilerHostTarget;
|
||||
|
||||
unstable?: boolean;
|
||||
writeFile: WriteFileCallback;
|
||||
}
|
||||
|
||||
|
@ -146,13 +145,26 @@ export class Host implements ts.CompilerHost {
|
|||
|
||||
/* Deno specific APIs */
|
||||
|
||||
constructor({ bundle = false, target, writeFile }: CompilerHostOptions) {
|
||||
constructor({
|
||||
bundle = false,
|
||||
target,
|
||||
unstable,
|
||||
writeFile,
|
||||
}: CompilerHostOptions) {
|
||||
this.#target = target;
|
||||
this.#writeFile = writeFile;
|
||||
if (bundle) {
|
||||
// options we need to change when we are generating a bundle
|
||||
Object.assign(this.#options, defaultBundlerOptions);
|
||||
}
|
||||
if (unstable) {
|
||||
this.#options.lib = [
|
||||
target === CompilerHostTarget.Worker
|
||||
? "lib.deno.worker.d.ts"
|
||||
: "lib.deno.window.d.ts",
|
||||
"lib.deno.unstable.d.ts",
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
configure(path: string, configurationText: string): ConfigureResponse {
|
||||
|
|
|
@ -11,7 +11,6 @@ export {
|
|||
export { build } from "./build.ts";
|
||||
export { chmodSync, chmod } from "./ops/fs/chmod.ts";
|
||||
export { chownSync, chown } from "./ops/fs/chown.ts";
|
||||
export { transpileOnly, compile, bundle } from "./compiler/api.ts";
|
||||
export { customInspect, inspect } from "./web/console.ts";
|
||||
export { copyFileSync, copyFile } from "./ops/fs/copy_file.ts";
|
||||
export {
|
||||
|
@ -20,8 +19,7 @@ export {
|
|||
DiagnosticItem,
|
||||
DiagnosticMessageChain,
|
||||
} from "./diagnostics.ts";
|
||||
export { chdir, cwd } from "./ops/fs/dir.ts";
|
||||
export { applySourceMap, formatDiagnostics } from "./ops/errors.ts";
|
||||
export { chdir } from "./ops/fs/dir.ts";
|
||||
export { errors } from "./errors.ts";
|
||||
export {
|
||||
File,
|
||||
|
@ -51,7 +49,6 @@ export {
|
|||
Closer,
|
||||
Seeker,
|
||||
} from "./io.ts";
|
||||
export { linkSync, link } from "./ops/fs/link.ts";
|
||||
export {
|
||||
makeTempDirSync,
|
||||
makeTempDir,
|
||||
|
@ -61,34 +58,8 @@ export {
|
|||
} from "./ops/fs/make_temp.ts";
|
||||
export { metrics, Metrics } from "./ops/runtime.ts";
|
||||
export { mkdirSync, mkdir, MkdirOptions } from "./ops/fs/mkdir.ts";
|
||||
export {
|
||||
connect,
|
||||
listen,
|
||||
listenDatagram,
|
||||
DatagramConn,
|
||||
Listener,
|
||||
Conn,
|
||||
ShutdownMode,
|
||||
shutdown,
|
||||
} from "./net.ts";
|
||||
export {
|
||||
dir,
|
||||
env,
|
||||
exit,
|
||||
execPath,
|
||||
hostname,
|
||||
loadavg,
|
||||
osRelease,
|
||||
} from "./ops/os.ts";
|
||||
export {
|
||||
permissions,
|
||||
PermissionName,
|
||||
PermissionState,
|
||||
PermissionStatus,
|
||||
Permissions,
|
||||
} from "./permissions.ts";
|
||||
export { openPlugin } from "./ops/plugins.ts";
|
||||
export { kill } from "./ops/process.ts";
|
||||
export { connect, listen, Listener, Conn } from "./net.ts";
|
||||
export { dir, env, exit, execPath, hostname } from "./ops/os.ts";
|
||||
export { run, RunOptions, Process, ProcessStatus } from "./process.ts";
|
||||
export { DirEntry, readDirSync, readDir } from "./ops/fs/read_dir.ts";
|
||||
export { readFileSync, readFile } from "./read_file.ts";
|
||||
|
@ -98,14 +69,10 @@ export { realPathSync, realPath } from "./ops/fs/real_path.ts";
|
|||
export { removeSync, remove, RemoveOptions } from "./ops/fs/remove.ts";
|
||||
export { renameSync, rename } from "./ops/fs/rename.ts";
|
||||
export { resources, close } from "./ops/resources.ts";
|
||||
export { signal, signals, Signal, SignalStream } from "./signals.ts";
|
||||
export { FileInfo, statSync, lstatSync, stat, lstat } from "./ops/fs/stat.ts";
|
||||
export { symlinkSync, symlink } from "./ops/fs/symlink.ts";
|
||||
export { connectTls, listenTls, startTls } from "./tls.ts";
|
||||
export { connectTls, listenTls } from "./tls.ts";
|
||||
export { truncateSync, truncate } from "./ops/fs/truncate.ts";
|
||||
export { isatty, setRaw } from "./ops/tty.ts";
|
||||
export { umask } from "./ops/fs/umask.ts";
|
||||
export { utimeSync, utime } from "./ops/fs/utime.ts";
|
||||
export { isatty } from "./ops/tty.ts";
|
||||
export { version } from "./version.ts";
|
||||
export { writeFileSync, writeFile, WriteFileOptions } from "./write_file.ts";
|
||||
export { writeTextFileSync, writeTextFile } from "./write_text_file.ts";
|
||||
|
|
26
cli/js/deno_unstable.ts
Normal file
26
cli/js/deno_unstable.ts
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
// This module exports unstable Deno APIs.
|
||||
|
||||
export { umask } from "./ops/fs/umask.ts";
|
||||
export { linkSync, link } from "./ops/fs/link.ts";
|
||||
export { symlinkSync, symlink } from "./ops/fs/symlink.ts";
|
||||
export { dir, loadavg, osRelease } from "./ops/os.ts";
|
||||
export { openPlugin } from "./ops/plugins.ts";
|
||||
export { transpileOnly, compile, bundle } from "./compiler/api.ts";
|
||||
export { applySourceMap, formatDiagnostics } from "./ops/errors.ts";
|
||||
export { signal, signals, Signal, SignalStream } from "./signals.ts";
|
||||
export { setRaw } from "./ops/tty.ts";
|
||||
export { utimeSync, utime } from "./ops/fs/utime.ts";
|
||||
export { ShutdownMode, shutdown } from "./net.ts";
|
||||
export { listen, listenDatagram, connect } from "./net_unstable.ts";
|
||||
export { cwd } from "./ops/fs/dir.ts";
|
||||
export { startTls } from "./tls.ts";
|
||||
export { kill } from "./ops/process.ts";
|
||||
export {
|
||||
permissions,
|
||||
PermissionName,
|
||||
PermissionState,
|
||||
PermissionStatus,
|
||||
Permissions,
|
||||
} from "./permissions.ts";
|
5
cli/js/globals_unstable.ts
Normal file
5
cli/js/globals_unstable.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
export const unstableMethods = {};
|
||||
|
||||
export const unstableProperties = {};
|
1172
cli/js/lib.deno.ns.d.ts
vendored
1172
cli/js/lib.deno.ns.d.ts
vendored
File diff suppressed because it is too large
Load diff
1192
cli/js/lib.deno.unstable.d.ts
vendored
Normal file
1192
cli/js/lib.deno.unstable.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
|
@ -48,6 +48,7 @@ export class ConnImpl implements Conn {
|
|||
close(this.rid);
|
||||
}
|
||||
|
||||
// TODO(lucacasonato): make this unavailable in stable
|
||||
closeWrite(): void {
|
||||
netOps.shutdown(this.rid, netOps.ShutdownMode.Write);
|
||||
}
|
||||
|
@ -141,59 +142,22 @@ export interface Conn extends Reader, Writer, Closer {
|
|||
export interface ListenOptions {
|
||||
port: number;
|
||||
hostname?: string;
|
||||
transport?: "tcp" | "udp";
|
||||
}
|
||||
|
||||
export interface UnixListenOptions {
|
||||
transport: "unix" | "unixpacket";
|
||||
path: string;
|
||||
transport?: "tcp";
|
||||
}
|
||||
|
||||
export function listen(
|
||||
options: ListenOptions & { transport?: "tcp" }
|
||||
): Listener;
|
||||
export function listen(
|
||||
options: UnixListenOptions & { transport: "unix" }
|
||||
): Listener;
|
||||
export function listen(options: ListenOptions | UnixListenOptions): Listener {
|
||||
let res;
|
||||
|
||||
if (options.transport === "unix") {
|
||||
res = netOps.listen(options);
|
||||
} else {
|
||||
res = netOps.listen({
|
||||
transport: "tcp",
|
||||
hostname: "127.0.0.1",
|
||||
...(options as ListenOptions),
|
||||
});
|
||||
}
|
||||
export function listen(options: ListenOptions): Listener {
|
||||
const res = netOps.listen({
|
||||
transport: "tcp",
|
||||
hostname: "127.0.0.1",
|
||||
...(options as ListenOptions),
|
||||
});
|
||||
|
||||
return new ListenerImpl(res.rid, res.localAddr);
|
||||
}
|
||||
|
||||
export function listenDatagram(
|
||||
options: ListenOptions & { transport: "udp" }
|
||||
): DatagramConn;
|
||||
export function listenDatagram(
|
||||
options: UnixListenOptions & { transport: "unixpacket" }
|
||||
): DatagramConn;
|
||||
export function listenDatagram(
|
||||
options: ListenOptions | UnixListenOptions
|
||||
): DatagramConn {
|
||||
let res;
|
||||
if (options.transport === "unixpacket") {
|
||||
res = netOps.listen(options);
|
||||
} else {
|
||||
res = netOps.listen({
|
||||
transport: "udp",
|
||||
hostname: "127.0.0.1",
|
||||
...(options as ListenOptions),
|
||||
});
|
||||
}
|
||||
|
||||
return new DatagramImpl(res.rid, res.localAddr);
|
||||
}
|
||||
|
||||
export interface ConnectOptions {
|
||||
port: number;
|
||||
hostname?: string;
|
||||
|
|
79
cli/js/net_unstable.ts
Normal file
79
cli/js/net_unstable.ts
Normal file
|
@ -0,0 +1,79 @@
|
|||
import * as netOps from "./ops/net.ts";
|
||||
import {
|
||||
Listener,
|
||||
DatagramConn,
|
||||
ListenerImpl,
|
||||
DatagramImpl,
|
||||
ConnectOptions,
|
||||
Conn,
|
||||
ConnImpl,
|
||||
listen as stableListen,
|
||||
connect as stableConnect,
|
||||
} from "./net.ts";
|
||||
|
||||
export interface ListenOptions {
|
||||
port: number;
|
||||
hostname?: string;
|
||||
transport?: "tcp" | "udp";
|
||||
}
|
||||
|
||||
export interface UnixListenOptions {
|
||||
transport: "unix" | "unixpacket";
|
||||
path: string;
|
||||
}
|
||||
|
||||
export function listen(
|
||||
options: ListenOptions & { transport?: "tcp" }
|
||||
): Listener;
|
||||
export function listen(
|
||||
options: UnixListenOptions & { transport: "unix" }
|
||||
): Listener;
|
||||
export function listen(options: ListenOptions | UnixListenOptions): Listener {
|
||||
if (options.transport === "unix") {
|
||||
const res = netOps.listen(options);
|
||||
return new ListenerImpl(res.rid, res.localAddr);
|
||||
} else {
|
||||
return stableListen(options as ListenOptions & { transport?: "tcp" });
|
||||
}
|
||||
}
|
||||
|
||||
export function listenDatagram(
|
||||
options: ListenOptions & { transport: "udp" }
|
||||
): DatagramConn;
|
||||
export function listenDatagram(
|
||||
options: UnixListenOptions & { transport: "unixpacket" }
|
||||
): DatagramConn;
|
||||
export function listenDatagram(
|
||||
options: ListenOptions | UnixListenOptions
|
||||
): DatagramConn {
|
||||
let res;
|
||||
if (options.transport === "unixpacket") {
|
||||
res = netOps.listen(options);
|
||||
} else {
|
||||
res = netOps.listen({
|
||||
transport: "udp",
|
||||
hostname: "127.0.0.1",
|
||||
...(options as ListenOptions),
|
||||
});
|
||||
}
|
||||
|
||||
return new DatagramImpl(res.rid, res.localAddr);
|
||||
}
|
||||
|
||||
export interface UnixConnectOptions {
|
||||
transport: "unix";
|
||||
path: string;
|
||||
}
|
||||
|
||||
export async function connect(options: UnixConnectOptions): Promise<Conn>;
|
||||
export async function connect(options: ConnectOptions): Promise<Conn>;
|
||||
export async function connect(
|
||||
options: ConnectOptions | UnixConnectOptions
|
||||
): Promise<Conn> {
|
||||
if (options.transport === "unix") {
|
||||
const res = await netOps.connect(options);
|
||||
return new ConnImpl(res.rid, res.remoteAddr!, res.localAddr!);
|
||||
} else {
|
||||
return stableConnect(options as ConnectOptions);
|
||||
}
|
||||
}
|
|
@ -3,20 +3,19 @@
|
|||
import { sendSync } from "./dispatch_json.ts";
|
||||
|
||||
export interface Start {
|
||||
cwd: string;
|
||||
pid: number;
|
||||
args: string[];
|
||||
location: string; // Absolute URL.
|
||||
repl: boolean;
|
||||
cwd: string;
|
||||
debugFlag: boolean;
|
||||
depsFlag: boolean;
|
||||
typesFlag: boolean;
|
||||
versionFlag: boolean;
|
||||
denoVersion: string;
|
||||
v8Version: string;
|
||||
tsVersion: string;
|
||||
location: string; // Absolute URL.
|
||||
noColor: boolean;
|
||||
pid: number;
|
||||
repl: boolean;
|
||||
target: string;
|
||||
tsVersion: string;
|
||||
unstableFlag: boolean;
|
||||
v8Version: string;
|
||||
versionFlag: boolean;
|
||||
}
|
||||
|
||||
export function opStart(): Start {
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
// - `bootstrapMainRuntime` - must be called once, when Isolate is created.
|
||||
// It sets up runtime by providing globals for `WindowScope` and adds `Deno` global.
|
||||
|
||||
import * as Deno from "./deno.ts";
|
||||
import * as denoNs from "./deno.ts";
|
||||
import * as denoUnstableNs from "./deno_unstable.ts";
|
||||
import * as csprng from "./ops/get_random_values.ts";
|
||||
import { exit } from "./ops/os.ts";
|
||||
import {
|
||||
|
@ -19,6 +20,7 @@ import {
|
|||
eventTargetProperties,
|
||||
setEventTargetData,
|
||||
} from "./globals.ts";
|
||||
import { unstableMethods, unstableProperties } from "./globals_unstable.ts";
|
||||
import { internalObject, internalSymbol } from "./internals.ts";
|
||||
import { setSignals } from "./signals.ts";
|
||||
import { replLoop } from "./repl.ts";
|
||||
|
@ -31,7 +33,7 @@ import { log, immutableDefine } from "./util.ts";
|
|||
// Add internal object to Deno object.
|
||||
// This is not exposed as part of the Deno types.
|
||||
// @ts-ignore
|
||||
Deno[internalSymbol] = internalObject;
|
||||
denoNs[internalSymbol] = internalObject;
|
||||
|
||||
let windowIsClosing = false;
|
||||
|
||||
|
@ -96,29 +98,44 @@ export function bootstrapMainRuntime(): void {
|
|||
}
|
||||
});
|
||||
|
||||
const s = runtime.start();
|
||||
const {
|
||||
args,
|
||||
cwd,
|
||||
location,
|
||||
noColor,
|
||||
pid,
|
||||
repl,
|
||||
unstableFlag,
|
||||
} = runtime.start();
|
||||
|
||||
const location = new LocationImpl(s.location);
|
||||
immutableDefine(globalThis, "location", location);
|
||||
const location_ = new LocationImpl(location);
|
||||
immutableDefine(globalThis, "location", location_);
|
||||
Object.freeze(globalThis.location);
|
||||
|
||||
Object.defineProperties(Deno, {
|
||||
pid: readOnly(s.pid),
|
||||
noColor: readOnly(s.noColor),
|
||||
args: readOnly(Object.freeze(s.args)),
|
||||
Object.defineProperties(denoNs, {
|
||||
pid: readOnly(pid),
|
||||
noColor: readOnly(noColor),
|
||||
args: readOnly(Object.freeze(args)),
|
||||
});
|
||||
|
||||
if (unstableFlag) {
|
||||
Object.defineProperties(globalThis, unstableMethods);
|
||||
Object.defineProperties(globalThis, unstableProperties);
|
||||
Object.assign(denoNs, denoUnstableNs);
|
||||
}
|
||||
|
||||
// Setup `Deno` global - we're actually overriding already
|
||||
// existing global `Deno` with `Deno` namespace from "./deno.ts".
|
||||
immutableDefine(globalThis, "Deno", Deno);
|
||||
immutableDefine(globalThis, "Deno", denoNs);
|
||||
Object.freeze(globalThis.Deno);
|
||||
Object.freeze(globalThis.Deno.core);
|
||||
Object.freeze(globalThis.Deno.core.sharedQueue);
|
||||
setSignals();
|
||||
|
||||
log("cwd", s.cwd);
|
||||
log("args", Deno.args);
|
||||
log("cwd", cwd);
|
||||
log("args", args);
|
||||
|
||||
if (s.repl) {
|
||||
if (repl) {
|
||||
replLoop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,9 @@ import {
|
|||
eventTargetProperties,
|
||||
setEventTargetData,
|
||||
} from "./globals.ts";
|
||||
import * as Deno from "./deno.ts";
|
||||
import { unstableMethods, unstableProperties } from "./globals_unstable.ts";
|
||||
import * as denoNs from "./deno.ts";
|
||||
import * as denoUnstableNs from "./deno_unstable.ts";
|
||||
import * as webWorkerOps from "./ops/web_worker.ts";
|
||||
import { LocationImpl } from "./web/location.ts";
|
||||
import { log, assert, immutableDefine } from "./util.ts";
|
||||
|
@ -32,7 +34,7 @@ import { setSignals } from "./signals.ts";
|
|||
// Add internal object to Deno object.
|
||||
// This is not exposed as part of the Deno types.
|
||||
// @ts-ignore
|
||||
Deno[internalSymbol] = internalObject;
|
||||
denoNs[internalSymbol] = internalObject;
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
|
@ -136,21 +138,31 @@ export function bootstrapWorkerRuntime(
|
|||
Object.defineProperties(globalThis, eventTargetProperties);
|
||||
Object.defineProperties(globalThis, { name: readOnly(name) });
|
||||
setEventTargetData(globalThis);
|
||||
const s = runtime.start(internalName ?? name);
|
||||
const { location, unstableFlag, pid, noColor, args } = runtime.start(
|
||||
internalName ?? name
|
||||
);
|
||||
|
||||
const location = new LocationImpl(s.location);
|
||||
immutableDefine(globalThis, "location", location);
|
||||
const location_ = new LocationImpl(location);
|
||||
immutableDefine(globalThis, "location", location_);
|
||||
Object.freeze(globalThis.location);
|
||||
|
||||
if (unstableFlag) {
|
||||
Object.defineProperties(globalThis, unstableMethods);
|
||||
Object.defineProperties(globalThis, unstableProperties);
|
||||
}
|
||||
|
||||
if (useDenoNamespace) {
|
||||
Object.defineProperties(Deno, {
|
||||
pid: readOnly(s.pid),
|
||||
noColor: readOnly(s.noColor),
|
||||
args: readOnly(Object.freeze(s.args)),
|
||||
if (unstableFlag) {
|
||||
Object.assign(denoNs, denoUnstableNs);
|
||||
}
|
||||
Object.defineProperties(denoNs, {
|
||||
pid: readOnly(pid),
|
||||
noColor: readOnly(noColor),
|
||||
args: readOnly(Object.freeze(args)),
|
||||
});
|
||||
// Setup `Deno` global - we're actually overriding already
|
||||
// existing global `Deno` with `Deno` namespace from "./deno.ts".
|
||||
immutableDefine(globalThis, "Deno", Deno);
|
||||
immutableDefine(globalThis, "Deno", denoNs);
|
||||
Object.freeze(globalThis.Deno);
|
||||
Object.freeze(globalThis.Deno.core);
|
||||
Object.freeze(globalThis.Deno.core.sharedQueue);
|
||||
|
|
28
cli/lib.rs
28
cli/lib.rs
|
@ -253,13 +253,23 @@ async fn print_file_info(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn get_types() -> String {
|
||||
format!(
|
||||
"{}\n{}\n{}",
|
||||
crate::js::DENO_NS_LIB,
|
||||
crate::js::SHARED_GLOBALS_LIB,
|
||||
crate::js::WINDOW_LIB
|
||||
)
|
||||
fn get_types(unstable: bool) -> String {
|
||||
if unstable {
|
||||
format!(
|
||||
"{}\n{}\n{}\n{}",
|
||||
crate::js::DENO_NS_LIB,
|
||||
crate::js::SHARED_GLOBALS_LIB,
|
||||
crate::js::WINDOW_LIB,
|
||||
crate::js::UNSTABLE_NS_LIB,
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"{}\n{}\n{}",
|
||||
crate::js::DENO_NS_LIB,
|
||||
crate::js::SHARED_GLOBALS_LIB,
|
||||
crate::js::WINDOW_LIB,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
async fn info_command(
|
||||
|
@ -409,7 +419,7 @@ async fn doc_command(
|
|||
let doc_parser = doc::DocParser::new(loader);
|
||||
|
||||
let parse_result = if source_file == "--builtin" {
|
||||
doc_parser.parse_source("lib.deno.d.ts", get_types().as_str())
|
||||
doc_parser.parse_source("lib.deno.d.ts", get_types(flags.unstable).as_str())
|
||||
} else {
|
||||
let module_specifier =
|
||||
ModuleSpecifier::resolve_url_or_path(&source_file).unwrap();
|
||||
|
@ -598,7 +608,7 @@ pub fn main() {
|
|||
return;
|
||||
}
|
||||
DenoSubcommand::Types => {
|
||||
let types = get_types();
|
||||
let types = get_types(flags.unstable);
|
||||
if let Err(e) = write_to_stdout_ignore_sigpipe(types.as_bytes()) {
|
||||
eprintln!("{}", e);
|
||||
std::process::exit(1);
|
||||
|
|
|
@ -24,18 +24,19 @@ fn op_start(
|
|||
|
||||
Ok(JsonOp::Sync(json!({
|
||||
// TODO(bartlomieju): `cwd` field is not used in JS, remove?
|
||||
"cwd": &env::current_dir().unwrap(),
|
||||
"pid": std::process::id(),
|
||||
"args": gs.flags.argv.clone(),
|
||||
"repl": gs.flags.subcommand == DenoSubcommand::Repl,
|
||||
"location": state.main_module.to_string(),
|
||||
"cwd": &env::current_dir().unwrap(),
|
||||
"debugFlag": gs.flags.log_level.map_or(false, |l| l == log::Level::Debug),
|
||||
"versionFlag": gs.flags.version,
|
||||
"v8Version": version::v8(),
|
||||
"denoVersion": version::DENO,
|
||||
"tsVersion": version::TYPESCRIPT,
|
||||
"location": state.main_module.to_string(),
|
||||
"noColor": !colors::use_color(),
|
||||
"pid": std::process::id(),
|
||||
"repl": gs.flags.subcommand == DenoSubcommand::Repl,
|
||||
"target": env!("TARGET"),
|
||||
"tsVersion": version::TYPESCRIPT,
|
||||
"unstableFlag": gs.flags.unstable,
|
||||
"v8Version": version::v8(),
|
||||
"versionFlag": gs.flags.version,
|
||||
})))
|
||||
}
|
||||
|
||||
|
|
|
@ -273,6 +273,7 @@ fn js_unit_tests() {
|
|||
let mut deno = util::deno_cmd()
|
||||
.current_dir(util::root_path())
|
||||
.arg("run")
|
||||
.arg("--unstable")
|
||||
.arg("--reload")
|
||||
.arg("-A")
|
||||
.arg("cli/js/tests/unit_test_runner.ts")
|
||||
|
@ -952,8 +953,9 @@ itest_ignore!(_024_import_no_ext_with_headers {
|
|||
output: "024_import_no_ext_with_headers.ts.out",
|
||||
});
|
||||
|
||||
// TODO(lucacasonato): remove --unstable when permissions goes stable
|
||||
itest!(_025_hrtime {
|
||||
args: "run --allow-hrtime --reload 025_hrtime.ts",
|
||||
args: "run --allow-hrtime --unstable --reload 025_hrtime.ts",
|
||||
output: "025_hrtime.ts.out",
|
||||
});
|
||||
|
||||
|
@ -1158,13 +1160,16 @@ itest!(_055_import_wasm_via_network {
|
|||
http_server: true,
|
||||
});
|
||||
|
||||
// TODO(lucacasonato): remove --unstable when cwd goes stable
|
||||
itest!(_056_make_temp_file_write_perm {
|
||||
args: "run --allow-write=./subdir/ 056_make_temp_file_write_perm.ts",
|
||||
args:
|
||||
"run --allow-write=./subdir/ --unstable 056_make_temp_file_write_perm.ts",
|
||||
output: "056_make_temp_file_write_perm.out",
|
||||
});
|
||||
|
||||
// TODO(lucacasonato): remove --unstable when permissions goes stable
|
||||
itest!(_057_revoke_permissions {
|
||||
args: "test -A 057_revoke_permissions.ts",
|
||||
args: "test -A --unstable 057_revoke_permissions.ts",
|
||||
output: "057_revoke_permissions.out",
|
||||
});
|
||||
|
||||
|
@ -1575,11 +1580,26 @@ itest!(top_level_for_await_ts {
|
|||
output: "top_level_for_await.out",
|
||||
});
|
||||
|
||||
itest!(unstable {
|
||||
args: "run unstable.js",
|
||||
itest!(unstable_disabled {
|
||||
args: "run --reload unstable.ts",
|
||||
check_stderr: true,
|
||||
exit_code: 70,
|
||||
output: "unstable.out",
|
||||
exit_code: 1,
|
||||
output: "unstable_disabled.out",
|
||||
});
|
||||
|
||||
itest!(unstable_enabled {
|
||||
args: "run --reload --unstable unstable.ts",
|
||||
output: "unstable_enabled.out",
|
||||
});
|
||||
|
||||
itest!(unstable_disabled_js {
|
||||
args: "run --reload unstable.js",
|
||||
output: "unstable_disabled_js.out",
|
||||
});
|
||||
|
||||
itest!(unstable_enabled_js {
|
||||
args: "run --reload --unstable unstable.ts",
|
||||
output: "unstable_enabled_js.out",
|
||||
});
|
||||
|
||||
itest!(_053_import_compression {
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
// This program should require the --unstable flag
|
||||
Deno.openPlugin("foo");
|
||||
console.log(Deno.loadavg);
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Unstable API 'Deno.openPlugin'. The --unstable flag must be provided.
|
1
cli/tests/unstable.ts
Normal file
1
cli/tests/unstable.ts
Normal file
|
@ -0,0 +1 @@
|
|||
console.log(Deno.loadavg);
|
5
cli/tests/unstable_disabled.out
Normal file
5
cli/tests/unstable_disabled.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
[WILDCARD]
|
||||
error TS2339: Property 'loadavg' does not exist on type 'typeof Deno'.
|
||||
console.log(Deno.loadavg);
|
||||
~~~~~~~
|
||||
at [WILDCARD]/cli/tests/unstable.ts:1:18
|
1
cli/tests/unstable_disabled_js.out
Normal file
1
cli/tests/unstable_disabled_js.out
Normal file
|
@ -0,0 +1 @@
|
|||
undefined
|
1
cli/tests/unstable_enabled.out
Normal file
1
cli/tests/unstable_enabled.out
Normal file
|
@ -0,0 +1 @@
|
|||
[Function: loadavg]
|
1
cli/tests/unstable_enabled_js.out
Normal file
1
cli/tests/unstable_enabled_js.out
Normal file
|
@ -0,0 +1 @@
|
|||
[Function: loadavg]
|
|
@ -9,7 +9,14 @@ const { test } = Deno;
|
|||
|
||||
async function startServer(): Promise<Deno.Process> {
|
||||
const server = Deno.run({
|
||||
cmd: [Deno.execPath(), "--allow-net", "--allow-read", "server.ts"],
|
||||
// TODO(lucacasonato): remove unstable once possible
|
||||
cmd: [
|
||||
Deno.execPath(),
|
||||
"--allow-net",
|
||||
"--allow-read",
|
||||
"--unstable",
|
||||
"server.ts",
|
||||
],
|
||||
cwd: "examples/chat",
|
||||
stdout: "piped",
|
||||
});
|
||||
|
|
|
@ -203,7 +203,8 @@ for (const s of scenes) {
|
|||
);
|
||||
|
||||
try {
|
||||
const args = [Deno.execPath(), "run"];
|
||||
// TODO(lucacasonato): remove unstable when stabilized
|
||||
const args = [Deno.execPath(), "run", "--unstable"];
|
||||
|
||||
if (s.read) {
|
||||
args.push("--allow-read");
|
||||
|
|
|
@ -112,7 +112,8 @@ for (const s of scenes) {
|
|||
let title = `test ${s.async ? "exists" : "existsSync"}("testdata/${s.file}")`;
|
||||
title += ` ${s.read ? "with" : "without"} --allow-read`;
|
||||
Deno.test(`[fs] existsPermission ${title}`, async function (): Promise<void> {
|
||||
const args = [Deno.execPath(), "run"];
|
||||
// TODO(lucacasonato): remove unstable when stabilized
|
||||
const args = [Deno.execPath(), "run", "--unstable"];
|
||||
|
||||
if (s.read) {
|
||||
args.push("--allow-read");
|
||||
|
|
|
@ -115,7 +115,7 @@ Deno.test("expandGlobIncludeDirs", async function (): Promise<void> {
|
|||
Deno.test("expandGlobPermError", async function (): Promise<void> {
|
||||
const exampleUrl = new URL("testdata/expand_wildcard.js", import.meta.url);
|
||||
const p = run({
|
||||
cmd: [execPath(), exampleUrl.toString()],
|
||||
cmd: [execPath(), "--unstable", exampleUrl.toString()],
|
||||
stdin: "null",
|
||||
stdout: "piped",
|
||||
stderr: "piped",
|
||||
|
|
|
@ -12,6 +12,7 @@ async function startFileServer(): Promise<void> {
|
|||
cmd: [
|
||||
Deno.execPath(),
|
||||
"run",
|
||||
"--unstable",
|
||||
"--allow-read",
|
||||
"--allow-net",
|
||||
"http/file_server.ts",
|
||||
|
@ -105,7 +106,14 @@ test("serveWithUnorthodoxFilename", async function (): Promise<void> {
|
|||
|
||||
test("servePermissionDenied", async function (): Promise<void> {
|
||||
const deniedServer = Deno.run({
|
||||
cmd: [Deno.execPath(), "run", "--allow-net", "http/file_server.ts"],
|
||||
// TODO(lucacasonato): remove unstable when stabilized
|
||||
cmd: [
|
||||
Deno.execPath(),
|
||||
"run",
|
||||
"--unstable",
|
||||
"--allow-net",
|
||||
"http/file_server.ts",
|
||||
],
|
||||
stdout: "piped",
|
||||
stderr: "piped",
|
||||
});
|
||||
|
@ -132,7 +140,14 @@ test("servePermissionDenied", async function (): Promise<void> {
|
|||
|
||||
test("printHelp", async function (): Promise<void> {
|
||||
const helpProcess = Deno.run({
|
||||
cmd: [Deno.execPath(), "run", "http/file_server.ts", "--help"],
|
||||
// TODO(lucacasonato): remove unstable when stabilized
|
||||
cmd: [
|
||||
Deno.execPath(),
|
||||
"run",
|
||||
"--unstable",
|
||||
"http/file_server.ts",
|
||||
"--help",
|
||||
],
|
||||
stdout: "piped",
|
||||
});
|
||||
assert(helpProcess.stdout != null);
|
||||
|
|
|
@ -6,7 +6,8 @@ const { connect, run, test } = Deno;
|
|||
let server: Deno.Process;
|
||||
async function startServer(): Promise<void> {
|
||||
server = run({
|
||||
cmd: [Deno.execPath(), "run", "-A", "http/racing_server.ts"],
|
||||
// TODO(lucacasonato): remove unstable when stabilized
|
||||
cmd: [Deno.execPath(), "run", "--unstable", "-A", "http/racing_server.ts"],
|
||||
stdout: "piped",
|
||||
});
|
||||
// Once racing server is ready it will write to its stdout.
|
||||
|
|
|
@ -213,7 +213,7 @@ def bundle_benchmark(deno_exe):
|
|||
for name, url in bundles.items():
|
||||
# bundle
|
||||
path = name + ".bundle.js"
|
||||
run([deno_exe, "bundle", url, path])
|
||||
run([deno_exe, "bundle", "--unstable", url, path])
|
||||
# get size of bundle
|
||||
assert os.path.exists(path)
|
||||
sizes[name] = os.path.getsize(path)
|
||||
|
|
|
@ -35,7 +35,11 @@ def get_port(port=None):
|
|||
def deno_tcp(deno_exe):
|
||||
port = get_port()
|
||||
deno_cmd = [
|
||||
deno_exe, "run", "--allow-net", "tools/deno_tcp.ts",
|
||||
# TODO(lucacasonato): remove unstable when stabilized
|
||||
deno_exe,
|
||||
"run",
|
||||
"--allow-net",
|
||||
"tools/deno_tcp.ts",
|
||||
server_addr(port)
|
||||
]
|
||||
print "http_benchmark testing DENO tcp."
|
||||
|
@ -45,7 +49,8 @@ def deno_tcp(deno_exe):
|
|||
def deno_http(deno_exe):
|
||||
port = get_port()
|
||||
deno_cmd = [
|
||||
deno_exe, "run", "--allow-net", "std/http/http_bench.ts",
|
||||
deno_exe, "run", "--allow-net", "--reload", "--unstable",
|
||||
"std/http/http_bench.ts",
|
||||
server_addr(port)
|
||||
]
|
||||
print "http_benchmark testing DENO using net/http."
|
||||
|
|
Loading…
Add table
Reference in a new issue