Pull request review commentdenoland/deno

[WIP] High precision

 hyper-rustls = "0.16.0" integer-atomics = "1.0.2" lazy_static = "1.3.0" libc = "0.2.49"+libmath = "0.2.1"

This can go now.

zekth

comment created time in 7 hours

Pull request review commentdenoland/deno

[WIP] High precision

 fn op_now(   data: libdeno::deno_buf, ) -> Box<Op> {   assert_eq!(data.len(), 0);-  let start = SystemTime::now();-  let since_the_epoch = start.duration_since(UNIX_EPOCH).unwrap();-  let time = since_the_epoch.as_secs() * 1000-    + u64::from(since_the_epoch.subsec_millis());+  let start = Instant::now();+  let since_the_epoch = start.duration_since(_isolate.start_time).as_nanos();+  let time = since_the_epoch;

Yeah, that seems surprising that it's required.

I guess you could just do time -=(time % REDUCED_TIME_PRECISION), would that be right? (e.g. 1000, so 1ms). You'd do that on just the subsec_nanos part.

zekth

comment created time in 10 hours

Pull request review commentdenoland/deno

[WIP] High precision

 fn op_now(   data: libdeno::deno_buf, ) -> Box<Op> {   assert_eq!(data.len(), 0);-  let start = SystemTime::now();-  let since_the_epoch = start.duration_since(UNIX_EPOCH).unwrap();-  let time = since_the_epoch.as_secs() * 1000-    + u64::from(since_the_epoch.subsec_millis());+  let start = Instant::now();+  let since_the_epoch = start.duration_since(_isolate.start_time).as_nanos();+  let time = since_the_epoch;

I think this can be simplified as isolate.start_time.elapsed()

I suspect returning (as_secs, subsec_nanos) as the msg is easier / avoids the u64 cast. (This means amending the NowRes table.)

I will give this a whirl soon. Overall this look great.

zekth

comment created time in 20 hours

Pull request review commentdenoland/deno

More permissions prompt options

 import pty import select import subprocess+import sys+import time -from util import build_path, executable_suffix+from util import build_path, executable_suffix, green_ok, red_failed  PERMISSIONS_PROMPT_TEST_TS = "tools/permission_prompt_test.ts" +PROMPT_PATTERN = b'⚠️'+FIRST_CHECK_FAILED_PATTERN = b'First check failed'+PERMISSION_DENIED_PATTERN = b'PermissionDenied: permission denied'+  # This function is copied from: # https://gist.github.com/hayd/4f46a68fc697ba8888a7b517a414583e # https://stackoverflow.com/q/52954248/1240268-def tty_capture(cmd, bytes_input):+def tty_capture(cmd, bytes_input, timeout=5):     """Capture the output of cmd with bytes_input to stdin,     with stdin, stdout and stderr as TTYs."""     mo, so = pty.openpty()  # provide tty to enable line-buffering     me, se = pty.openpty()     mi, si = pty.openpty()     fdmap = {mo: 'stdout', me: 'stderr', mi: 'stdin'} +    timeout_exact = time.time() + timeout     p = subprocess.Popen(         cmd, bufsize=1, stdin=si, stdout=so, stderr=se, close_fds=True)     os.write(mi, bytes_input) -    timeout = .04  # seconds+    select_timeout = .04  #seconds     res = {'stdout': b'', 'stderr': b''}     while True:-        ready, _, _ = select.select([mo, me], [], [], timeout)+        ready, _, _ = select.select([mo, me], [], [], select_timeout)         if ready:             for fd in ready:                 data = os.read(fd, 512)                 if not data:                     break                 res[fdmap[fd]] += data-        elif p.poll() is not None:  # select timed-out+        elif p.poll() is not None or time.time(+        ) > timeout_exact:  # select timed-out             break  # p exited     for fd in [si, so, se, mi, mo, me]:         os.close(fd)  # can't do it sooner: it leads to errno.EIO error     p.wait()     return p.returncode, res['stdout'], res['stderr']  +def wrap_test(test_name, test_method, *argv):+    sys.stdout.write(test_name + " ... ")+    try:+        test_method(*argv)+        print green_ok()+    except AssertionError:+        print red_failed()+        raise++ class Prompt(object):-    def __init__(self, deno_exe):+    def __init__(self, deno_exe, test_types):         self.deno_exe = deno_exe+        self.test_types = test_types -    def run(self,-            arg,-            bytes_input,-            allow_read=False,-            allow_write=False,-            allow_net=False,-            allow_env=False,-            allow_run=False,-            no_prompt=False):+    def run(self, arg, bytes_input, args=None):         "Returns (return_code, stdout, stderr)."-        cmd = [self.deno_exe, PERMISSIONS_PROMPT_TEST_TS, arg]-        if allow_read:-            cmd.append("--allow-read")-        if allow_write:-            cmd.append("--allow-write")-        if allow_net:-            cmd.append("--allow-net")-        if allow_env:-            cmd.append("--allow-env")-        if allow_run:-            cmd.append("--allow-run")-        if no_prompt:-            cmd.append("--no-prompt")+        if args is None:+            args = []+        cmd = [self.deno_exe, PERMISSIONS_PROMPT_TEST_TS, arg] + args         return tty_capture(cmd, bytes_input)      def warm_up(self):         # ignore the ts compiling message-        self.run('needsWrite', b'', allow_write=True)--    def test_read_yes(self):-        code, stdout, stderr = self.run('needsRead', b'y\n')+        self.run('needsWrite', b'', ["--allow-write"])++    def test(self):+        for test_type in self.test_types:+            test_name_base = "test_" + test_type+            wrap_test(test_name_base + "_allow_flag", self.test_allow_flag,

How so? if you debug then you can access the variable name.

afinch7

comment created time in a day

Pull request review commentdenoland/deno

More permissions prompt options

 import pty import select import subprocess+import sys+import time -from util import build_path, executable_suffix+from util import build_path, executable_suffix, green_ok, red_failed  PERMISSIONS_PROMPT_TEST_TS = "tools/permission_prompt_test.ts" +PROMPT_PATTERN = b'⚠️'+FIRST_CHECK_FAILED_PATTERN = b'First check failed'+PERMISSION_DENIED_PATTERN = b'PermissionDenied: permission denied'+  # This function is copied from: # https://gist.github.com/hayd/4f46a68fc697ba8888a7b517a414583e # https://stackoverflow.com/q/52954248/1240268-def tty_capture(cmd, bytes_input):+def tty_capture(cmd, bytes_input, timeout=5):     """Capture the output of cmd with bytes_input to stdin,     with stdin, stdout and stderr as TTYs."""     mo, so = pty.openpty()  # provide tty to enable line-buffering     me, se = pty.openpty()     mi, si = pty.openpty()     fdmap = {mo: 'stdout', me: 'stderr', mi: 'stdin'} +    timeout_exact = time.time() + timeout     p = subprocess.Popen(         cmd, bufsize=1, stdin=si, stdout=so, stderr=se, close_fds=True)     os.write(mi, bytes_input) -    timeout = .04  # seconds+    select_timeout = .04  #seconds     res = {'stdout': b'', 'stderr': b''}     while True:-        ready, _, _ = select.select([mo, me], [], [], timeout)+        ready, _, _ = select.select([mo, me], [], [], select_timeout)         if ready:             for fd in ready:                 data = os.read(fd, 512)                 if not data:                     break                 res[fdmap[fd]] += data-        elif p.poll() is not None:  # select timed-out+        elif p.poll() is not None or time.time(+        ) > timeout_exact:  # select timed-out             break  # p exited     for fd in [si, so, se, mi, mo, me]:         os.close(fd)  # can't do it sooner: it leads to errno.EIO error     p.wait()     return p.returncode, res['stdout'], res['stderr']  +def wrap_test(test_name, test_method, *argv):+    sys.stdout.write(test_name + " ... ")+    try:+        test_method(*argv)+        print green_ok()+    except AssertionError:+        print red_failed()+        raise++ class Prompt(object):-    def __init__(self, deno_exe):+    def __init__(self, deno_exe, test_types):         self.deno_exe = deno_exe+        self.test_types = test_types -    def run(self,-            arg,-            bytes_input,-            allow_read=False,-            allow_write=False,-            allow_net=False,-            allow_env=False,-            allow_run=False,-            no_prompt=False):+    def run(self, arg, bytes_input, args=None):         "Returns (return_code, stdout, stderr)."-        cmd = [self.deno_exe, PERMISSIONS_PROMPT_TEST_TS, arg]-        if allow_read:-            cmd.append("--allow-read")-        if allow_write:-            cmd.append("--allow-write")-        if allow_net:-            cmd.append("--allow-net")-        if allow_env:-            cmd.append("--allow-env")-        if allow_run:-            cmd.append("--allow-run")-        if no_prompt:-            cmd.append("--no-prompt")+        if args is None:+            args = []+        cmd = [self.deno_exe, PERMISSIONS_PROMPT_TEST_TS, arg] + args         return tty_capture(cmd, bytes_input)      def warm_up(self):         # ignore the ts compiling message-        self.run('needsWrite', b'', allow_write=True)--    def test_read_yes(self):-        code, stdout, stderr = self.run('needsRead', b'y\n')+        self.run('needsWrite', b'', ["--allow-write"])++    def test(self):+        for test_type in self.test_types:+            test_name_base = "test_" + test_type+            wrap_test(test_name_base + "_allow_flag", self.test_allow_flag,+                      test_type)+            wrap_test(test_name_base + "_yes_yes", self.test_yes_yes,+                      test_type)+            wrap_test(test_name_base + "_yes_no", self.test_yes_no, test_type)+            wrap_test(test_name_base + "_no_no", self.test_no_no, test_type)+            wrap_test(test_name_base + "_no_yes", self.test_no_yes, test_type)+            wrap_test(test_name_base + "_allow", self.test_allow, test_type)+            wrap_test(test_name_base + "_deny", self.test_deny, test_type)+            wrap_test(test_name_base + "_unrecognized_option",+                      self.test_unrecognized_option, test_type)+            wrap_test(test_name_base + "_no_prompt", self.test_no_prompt,+                      test_type)+            wrap_test(test_name_base + "_no_prompt_allow",+                      self.test_no_prompt_allow, test_type)++    def test_allow_flag(self, test_type):+        code, stdout, stderr = self.run("needs" + test_type.capitalize(), b'',

I wonder if it's worth have self.run take test_type as it's first argument.

afinch7

comment created time in a day

Pull request review commentdenoland/deno

More permissions prompt options

 import pty import select import subprocess+import sys+import time -from util import build_path, executable_suffix+from util import build_path, executable_suffix, green_ok, red_failed  PERMISSIONS_PROMPT_TEST_TS = "tools/permission_prompt_test.ts" +PROMPT_PATTERN = b'⚠️'+FIRST_CHECK_FAILED_PATTERN = b'First check failed'+PERMISSION_DENIED_PATTERN = b'PermissionDenied: permission denied'+  # This function is copied from: # https://gist.github.com/hayd/4f46a68fc697ba8888a7b517a414583e # https://stackoverflow.com/q/52954248/1240268-def tty_capture(cmd, bytes_input):+def tty_capture(cmd, bytes_input, timeout=5):     """Capture the output of cmd with bytes_input to stdin,     with stdin, stdout and stderr as TTYs."""     mo, so = pty.openpty()  # provide tty to enable line-buffering     me, se = pty.openpty()     mi, si = pty.openpty()     fdmap = {mo: 'stdout', me: 'stderr', mi: 'stdin'} +    timeout_exact = time.time() + timeout     p = subprocess.Popen(         cmd, bufsize=1, stdin=si, stdout=so, stderr=se, close_fds=True)     os.write(mi, bytes_input) -    timeout = .04  # seconds+    select_timeout = .04  #seconds     res = {'stdout': b'', 'stderr': b''}     while True:-        ready, _, _ = select.select([mo, me], [], [], timeout)+        ready, _, _ = select.select([mo, me], [], [], select_timeout)         if ready:             for fd in ready:                 data = os.read(fd, 512)                 if not data:                     break                 res[fdmap[fd]] += data-        elif p.poll() is not None:  # select timed-out+        elif p.poll() is not None or time.time(+        ) > timeout_exact:  # select timed-out             break  # p exited     for fd in [si, so, se, mi, mo, me]:         os.close(fd)  # can't do it sooner: it leads to errno.EIO error     p.wait()     return p.returncode, res['stdout'], res['stderr']  +def wrap_test(test_name, test_method, *argv):+    sys.stdout.write(test_name + " ... ")+    try:+        test_method(*argv)+        print green_ok()+    except AssertionError:+        print red_failed()+        raise++ class Prompt(object):-    def __init__(self, deno_exe):+    def __init__(self, deno_exe, test_types):         self.deno_exe = deno_exe+        self.test_types = test_types -    def run(self,-            arg,-            bytes_input,-            allow_read=False,-            allow_write=False,-            allow_net=False,-            allow_env=False,-            allow_run=False,-            no_prompt=False):+    def run(self, arg, bytes_input, args=None):         "Returns (return_code, stdout, stderr)."-        cmd = [self.deno_exe, PERMISSIONS_PROMPT_TEST_TS, arg]-        if allow_read:-            cmd.append("--allow-read")-        if allow_write:-            cmd.append("--allow-write")-        if allow_net:-            cmd.append("--allow-net")-        if allow_env:-            cmd.append("--allow-env")-        if allow_run:-            cmd.append("--allow-run")-        if no_prompt:-            cmd.append("--no-prompt")+        if args is None:+            args = []+        cmd = [self.deno_exe, PERMISSIONS_PROMPT_TEST_TS, arg] + args         return tty_capture(cmd, bytes_input)      def warm_up(self):         # ignore the ts compiling message-        self.run('needsWrite', b'', allow_write=True)--    def test_read_yes(self):-        code, stdout, stderr = self.run('needsRead', b'y\n')+        self.run('needsWrite', b'', ["--allow-write"])++    def test(self):+        for test_type in self.test_types:+            test_name_base = "test_" + test_type+            wrap_test(test_name_base + "_allow_flag", self.test_allow_flag,

I think this would be clearer as a second for loop.

afinch7

comment created time in a day

Pull request review commentdenoland/deno

More permissions prompt options

 import pty import select import subprocess+import sys+import time -from util import build_path, executable_suffix+from util import build_path, executable_suffix, green_ok, red_failed  PERMISSIONS_PROMPT_TEST_TS = "tools/permission_prompt_test.ts" +PROMPT_PATTERN = b'⚠️'+FIRST_CHECK_FAILED_PATTERN = b'First check failed'+PERMISSION_DENIED_PATTERN = b'PermissionDenied: permission denied'+  # This function is copied from: # https://gist.github.com/hayd/4f46a68fc697ba8888a7b517a414583e # https://stackoverflow.com/q/52954248/1240268-def tty_capture(cmd, bytes_input):+def tty_capture(cmd, bytes_input, timeout=5):     """Capture the output of cmd with bytes_input to stdin,     with stdin, stdout and stderr as TTYs."""     mo, so = pty.openpty()  # provide tty to enable line-buffering     me, se = pty.openpty()     mi, si = pty.openpty()     fdmap = {mo: 'stdout', me: 'stderr', mi: 'stdin'} +    timeout_exact = time.time() + timeout     p = subprocess.Popen(         cmd, bufsize=1, stdin=si, stdout=so, stderr=se, close_fds=True)     os.write(mi, bytes_input) -    timeout = .04  # seconds+    select_timeout = .04  #seconds     res = {'stdout': b'', 'stderr': b''}     while True:-        ready, _, _ = select.select([mo, me], [], [], timeout)+        ready, _, _ = select.select([mo, me], [], [], select_timeout)         if ready:             for fd in ready:                 data = os.read(fd, 512)                 if not data:                     break                 res[fdmap[fd]] += data-        elif p.poll() is not None:  # select timed-out+        elif p.poll() is not None or time.time(+        ) > timeout_exact:  # select timed-out             break  # p exited

Does p not need to be killed in the time out case? Or does closing the fds have the same effect?

afinch7

comment created time in a day

issue commentdenoland/registry

Fen can't be reach through https://deno.land/x/fen

It looks like you missed a trailing slash:

-     "url": "https://raw.githubusercontent.com/fen-land/deno-fen/${b}", 
+     "url": "https://raw.githubusercontent.com/fen-land/deno-fen/${b}/", 
mxz96102

comment created time in 2 days

startedthen/then-request

started time in 2 days

pull request commentdenoland/deno_std

[WIP] feat: add http client module

Is this like python's requests library?

I wonder if this should be in requests directory (and take ideas from that API)? There's also a Scala port requests and it's really great.

axetroy

comment created time in 2 days

Pull request review commentdenoland/deno

More permissions prompt options

 def wrap_test(test_method, test_name):   class Prompt(object):-    def __init__(self, deno_exe):+    def __init__(self, deno_exe, test_types):         self.deno_exe = deno_exe+        self.test_types = test_types -    def run(self,-            arg,-            bytes_input,-            allow_read=False,-            allow_write=False,-            allow_net=False,-            allow_env=False,-            allow_run=False,-            no_prompt=False):+    def run(self, arg, bytes_input, args=[]):         "Returns (return_code, stdout, stderr)."-        cmd = [self.deno_exe, PERMISSIONS_PROMPT_TEST_TS, arg]-        if allow_read:-            cmd.append("--allow-read")-        if allow_write:-            cmd.append("--allow-write")-        if allow_net:-            cmd.append("--allow-net")-        if allow_env:-            cmd.append("--allow-env")-        if allow_run:-            cmd.append("--allow-run")-        if no_prompt:-            cmd.append("--no-prompt")+        cmd = [self.deno_exe, PERMISSIONS_PROMPT_TEST_TS, arg] + args         return tty_capture(cmd, bytes_input)      def warm_up(self):         # ignore the ts compiling message         self.run('needsWrite', b'', allow_write=True) -    def test_read_yes(self):-        sys.stdout.write("test_read_yes ...")-        code, stdout, stderr = self.run('needsRead', b'y\n')+    def test(self):+        for test_type in self.test_types:+            test_name_base = "test_" + test_type+            sys.stdout.write(test_name_base + "_allow_flag" + " ... ")+            self.test_allow_flag(test_type)+            print green_ok()+            sys.stdout.write(test_name_base + "_yes_yes" + " ... ")+            self.test_yes_yes(test_type)

Why not iterate through all attributes on the class that start with test_

afinch7

comment created time in 2 days

pull request commentdenoland/deno

Remove specific version of std

Specifying the version is good to avoid the issue which happened last time: breaking std changes to support master. Also, it's a good introduction to how versioning works.

sh7dm

comment created time in 3 days

Pull request review commentdenoland/deno

More permissions prompt options

 use ansi_term::Style; use crate::errors::permission_denied; use crate::errors::DenoResult; use std::io;-use std::sync::atomic::{AtomicBool, Ordering};+use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};+use std::sync::Arc;++/// Tri-state value for storing permission state+pub enum PermissionAccessorState {+  Allow = 0,+  Ask = 1,+  Deny = 2,+}++impl From<usize> for PermissionAccessorState {+  fn from(val: usize) -> Self {+    match val {+      0 => PermissionAccessorState::Allow,+      1 => PermissionAccessorState::Ask,+      2 => PermissionAccessorState::Deny,+      _ => unreachable!(),+    }+  }+}++impl From<bool> for PermissionAccessorState {+  fn from(val: bool) -> Self {+    match val {+      true => PermissionAccessorState::Allow,+      false => PermissionAccessorState::Ask,+    }+  }+}++#[derive(Debug)]+pub struct PermissionAccessor {+  state: Arc<AtomicUsize>,+}++impl PermissionAccessor {+  pub fn new(state: PermissionAccessorState) -> Self {+    Self {+      state: Arc::new(AtomicUsize::new(state as usize)),+    }+  }++  pub fn is_allow(&self) -> bool {+    match self.get_state() {+      PermissionAccessorState::Allow => true,+      _ => false,+    }+  }++  /// If the state is "Allow" walk it back to the default "Ask"+  /// Don't do anything if state is "Deny"+  pub fn revoke(&self) {+    if self.is_allow() {+      self.ask();+    }+  }++  pub fn allow(&self) {+    self.set_state(PermissionAccessorState::Allow)+  }++  pub fn ask(&self) {+    self.set_state(PermissionAccessorState::Ask)+  }++  pub fn deny(&self) {+    self.set_state(PermissionAccessorState::Deny)+  }++  /// Update this accessors state based on a PromptResult value+  /// This will only update the state if the PromptResult value+  /// is one of the "Always" values+  pub fn update_with_prompt_result(&self, prompt_result: &PromptResult) {+    match prompt_result {+      PromptResult::AllowAlways => self.allow(),+      PromptResult::DenyAlways => self.deny(),+      _ => {}+    }+  }++  #[inline]+  pub fn get_state(&self) -> PermissionAccessorState {+    self.state.load(Ordering::SeqCst).into()+  }+  fn set_state(&self, state: PermissionAccessorState) {+    self.state.store(state as usize, Ordering::SeqCst)+  }+}++impl From<bool> for PermissionAccessor {+  fn from(val: bool) -> Self {+    Self::new(PermissionAccessorState::from(val))+  }+}++impl Default for PermissionAccessor {+  fn default() -> Self {+    Self {+      state: Arc::new(AtomicUsize::new(PermissionAccessorState::Ask as usize)),+    }+  }+}  #[cfg_attr(feature = "cargo-clippy", allow(stutter))] #[derive(Debug, Default)] pub struct DenoPermissions {   // Keep in sync with src/permissions.ts-  pub allow_read: AtomicBool,-  pub allow_write: AtomicBool,-  pub allow_net: AtomicBool,-  pub allow_env: AtomicBool,-  pub allow_run: AtomicBool,+  pub allow_read: PermissionAccessor,+  pub allow_write: PermissionAccessor,+  pub allow_net: PermissionAccessor,+  pub allow_env: PermissionAccessor,+  pub allow_run: PermissionAccessor,   pub no_prompts: AtomicBool, }  impl DenoPermissions {   pub fn from_flags(flags: &DenoFlags) -> Self {     Self {-      allow_read: AtomicBool::new(flags.allow_read),-      allow_write: AtomicBool::new(flags.allow_write),-      allow_env: AtomicBool::new(flags.allow_env),-      allow_net: AtomicBool::new(flags.allow_net),-      allow_run: AtomicBool::new(flags.allow_run),+      allow_read: PermissionAccessor::from(flags.allow_read),+      allow_write: PermissionAccessor::from(flags.allow_write),+      allow_env: PermissionAccessor::from(flags.allow_env),+      allow_net: PermissionAccessor::from(flags.allow_net),+      allow_run: PermissionAccessor::from(flags.allow_run),       no_prompts: AtomicBool::new(flags.no_prompts),     }   }    pub fn check_run(&self) -> DenoResult<()> {-    if self.allow_run.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r = self.try_permissions_prompt("access to run a subprocess");-    if r.is_ok() {-      self.allow_run.store(true, Ordering::SeqCst);+    match self.allow_run.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => {+        match self.try_permissions_prompt("access to run a subprocess") {+          Err(e) => Err(e),+          Ok(v) => {+            self.allow_run.update_with_prompt_result(&v);+            v.check()?;+            Ok(())+          }+        }+      }+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_read(&self, filename: &str) -> DenoResult<()> {-    if self.allow_read.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r =-      self.try_permissions_prompt(&format!("read access to \"{}\"", filename));;-    if r.is_ok() {-      self.allow_read.store(true, Ordering::SeqCst);+    match self.allow_read.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => match self+        .try_permissions_prompt(&format!("read access to \"{}\"", filename))+      {+        Err(e) => Err(e),+        Ok(v) => {+          self.allow_run.update_with_prompt_result(&v);+          v.check()?;+          Ok(())+        }+      },+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_write(&self, filename: &str) -> DenoResult<()> {-    if self.allow_write.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r =-      self.try_permissions_prompt(&format!("write access to \"{}\"", filename));;-    if r.is_ok() {-      self.allow_write.store(true, Ordering::SeqCst);+    match self.allow_write.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => match self+        .try_permissions_prompt(&format!("write access to \"{}\"", filename))+      {+        Err(e) => Err(e),+        Ok(v) => {+          self.allow_run.update_with_prompt_result(&v);+          v.check()?;+          Ok(())+        }+      },+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_net(&self, domain_name: &str) -> DenoResult<()> {-    if self.allow_net.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r = self.try_permissions_prompt(&format!(-      "network access to \"{}\"",-      domain_name-    ));-    if r.is_ok() {-      self.allow_net.store(true, Ordering::SeqCst);+    match self.allow_net.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => match self.try_permissions_prompt(+        &format!("network access to \"{}\"", domain_name),+      ) {+        Err(e) => Err(e),+        Ok(v) => {+          self.allow_run.update_with_prompt_result(&v);+          v.check()?;+          Ok(())+        }+      },+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    pub fn check_env(&self) -> DenoResult<()> {-    if self.allow_env.load(Ordering::SeqCst) {-      return Ok(());-    };-    // TODO get location (where access occurred)-    let r = self.try_permissions_prompt(&"access to environment variables");-    if r.is_ok() {-      self.allow_env.store(true, Ordering::SeqCst);+    match self.allow_env.get_state() {+      PermissionAccessorState::Allow => Ok(()),+      PermissionAccessorState::Ask => {+        match self.try_permissions_prompt("access to environment variables") {+          Err(e) => Err(e),+          Ok(v) => {+            self.allow_run.update_with_prompt_result(&v);+            v.check()?;+            Ok(())+          }+        }+      }+      PermissionAccessorState::Deny => Err(permission_denied()),     }-    r   }    /// Try to present the user with a permission prompt   /// will error with permission_denied if no_prompts is enabled-  fn try_permissions_prompt(&self, message: &str) -> DenoResult<()> {+  fn try_permissions_prompt(&self, message: &str) -> DenoResult<PromptResult> {     if self.no_prompts.load(Ordering::SeqCst) {       return Err(permission_denied());     }+    if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) {+      return Err(permission_denied());+    };     permission_prompt(message)   }    pub fn allows_run(&self) -> bool {-    return self.allow_run.load(Ordering::SeqCst);+    return self.allow_run.is_allow();   }    pub fn allows_read(&self) -> bool {-    return self.allow_read.load(Ordering::SeqCst);+    return self.allow_read.is_allow();   }    pub fn allows_write(&self) -> bool {-    return self.allow_write.load(Ordering::SeqCst);+    return self.allow_write.is_allow();   }    pub fn allows_net(&self) -> bool {-    return self.allow_net.load(Ordering::SeqCst);+    return self.allow_net.is_allow();   }    pub fn allows_env(&self) -> bool {-    return self.allow_env.load(Ordering::SeqCst);+    return self.allow_env.is_allow();   }    pub fn revoke_run(&self) -> DenoResult<()> {-    self.allow_run.store(false, Ordering::SeqCst);+    self.allow_run.revoke();     return Ok(());   }    pub fn revoke_read(&self) -> DenoResult<()> {-    self.allow_read.store(false, Ordering::SeqCst);+    self.allow_read.revoke();     return Ok(());   }    pub fn revoke_write(&self) -> DenoResult<()> {-    self.allow_write.store(false, Ordering::SeqCst);+    self.allow_write.revoke();     return Ok(());   }    pub fn revoke_net(&self) -> DenoResult<()> {-    self.allow_net.store(false, Ordering::SeqCst);+    self.allow_net.revoke();     return Ok(());   }    pub fn revoke_env(&self) -> DenoResult<()> {-    self.allow_env.store(false, Ordering::SeqCst);+    self.allow_env.revoke();     return Ok(());   }+} -  pub fn default() -> Self {-    Self {-      allow_read: AtomicBool::new(false),-      allow_write: AtomicBool::new(false),-      allow_env: AtomicBool::new(false),-      allow_net: AtomicBool::new(false),-      allow_run: AtomicBool::new(false),-      ..Default::default()+/// Quad-state value for representing user input on permission prompt+#[derive(Debug, Clone)]+pub enum PromptResult {+  AllowAlways = 0,+  AllowOnce = 1,+  DenyOnce = 2,+  DenyAlways = 3,+}++impl PromptResult {+  /// If value is any form of deny this will error with permission_denied+  pub fn check(&self) -> DenoResult<()> {+    match self {+      PromptResult::DenyOnce => Err(permission_denied()),+      PromptResult::DenyAlways => Err(permission_denied()),+      _ => Ok(()),     }   } } -fn permission_prompt(message: &str) -> DenoResult<()> {-  if !atty::is(atty::Stream::Stdin) || !atty::is(atty::Stream::Stderr) {-    return Err(permission_denied());-  };-  let msg = format!("⚠️  Deno requests {}. Grant? [yN] ", message);+fn permission_prompt(message: &str) -> DenoResult<PromptResult> {+  let msg = format!("⚠️  Deno requests {}. Grant? [a/y/n/d (a = allow always, y = allow once, n = deny once, d = deny always)] ", message);   // print to stderr so that if deno is > to a file this is still displayed.   eprint!("{}", Style::new().bold().paint(msg));-  let mut input = String::new();-  let stdin = io::stdin();-  let _nread = stdin.read_line(&mut input)?;-  let ch = input.chars().next().unwrap();-  let is_yes = ch == 'y' || ch == 'Y';-  if is_yes {-    Ok(())-  } else {-    Err(permission_denied())+  loop {+    let mut input = String::new();+    let stdin = io::stdin();+    let _nread = stdin.read_line(&mut input)?;+    let ch = input.chars().next().unwrap();+    match ch.to_ascii_lowercase() {+      'a' => return Ok(PromptResult::AllowAlways),+      'y' => return Ok(PromptResult::AllowOnce),+      'n' => return Ok(PromptResult::DenyOnce),+      'd' => return Ok(PromptResult::DenyAlways),+      _ => {+        // If we don't get a recognized option try again.+        let msg_again = format!("Unrecognized option '{}' [a/y/n/d (a = allow always, y = allow once, n = deny once, d = deny always)] ", ch);+        eprint!("{}", Style::new().bold().paint(msg_again));+      }

I think there is a permission_prompt.py file which could be amended...

afinch7

comment created time in 3 days

pull request commentdenoland/deno

Core integration attempt #5

You might like to run cargo clippy, it raises a few suggestions (not sure whether they are actually perf issues though).

ry

comment created time in 4 days

issue commentnodejs/node

Dependency v8 is not Python 3 compatible

Is it the case in v8 CI tooling is still py2 only? If not, have all v8 scripts actually been run in py3, or is it expected there are still many issues to uncover and overcome?

cclauss

comment created time in 4 days

issue commentnodejs/node

Dependency v8 is not Python 3 compatible

Just to clarify: all v8 build scripts can run and are tested in CI on py3 as well as py2? So it's not just syntax that's updated but code now can be successfully executed in either py2 or py3?

If so, fantastic work!

cclauss

comment created time in 5 days

pull request commentbartlomieju/deno-postgres

Refactor query and pool tests to use a shared setup

@bartlomieju bump!

hayd

comment created time in 5 days

pull request commentdenoland/deno

More permissions prompt options

Would this allow using a String rather than Boolean one day? E.g. allowing web by domain? #1639

afinch7

comment created time in 5 days

MemberEvent

issue commentdenoland/deno_std

discuss: all test file's name should end with _test.ts

I think the regex /(test|.+_test).ts/ is reasonable.

I don't think there's a huge point in talking about this until https://github.com/denoland/deno_std/issues/193

axetroy

comment created time in 6 days

CommitCommentEvent

pull request commentdenoland/deno

No prompts flag for non interactive environments.

https://github.com/denoland/deno/pull/1591/files has some relevant tests

afinch7

comment created time in 7 days

Pull request review commentdenoland/deno

No prompts flag for non interactive environments.

 pub fn set_flags(   opts.optflag("", "allow-env", "Allow environment access");   opts.optflag("", "allow-run", "Allow running subprocesses");   opts.optflag("A", "allow-all", "Allow all permissions");+  opts.optflag("", "no-prompt", "Do not use prompts");

what about --no (as analogous to --yes e.g. of unix tools)

afinch7

comment created time in 7 days

pull request commentdenoland/deno

Add path and name to FileInfo from stat and lstat

I can rebase this sometime in the next few days.

hayd

comment created time in 7 days

pull request commentdenoland/deno

WIP add homebrew file

I pushed a version of this to the PR, and I think I've added you as a collaborator so hopefully you can push directly there now.

ry

comment created time in 7 days

push eventhayd/homebrew-core

Caleb Xu

commit sha 6ef2c04bc93fe48b3c02fa5ebf08b6c22fa1aacf

abcmidi 2019.02.08 Closes #37192. Signed-off-by: FX Coudert <fxcoudert@gmail.com>

view details

BrewTestBot

commit sha 083ad8d1777c7bdfab2bcb510b3defa33fb63952

abcmidi: update 2019.02.08 bottle.

view details

Caleb Xu

commit sha d9754827bcbddcb03e5265275f8fec6f5044bcc2

abcde 2.9.3 Closes #37191. Signed-off-by: FX Coudert <fxcoudert@gmail.com>

view details

BrewTestBot

commit sha f601c724b750909ab343ad0db7ffa181a978b256

abcde: update 2.9.3 bottle.

view details

Yurii Kolesnykov

commit sha 3653ba2ca35857bd1a8c287033b08876e5c2f350

mesa 18.3.4 Closes #37199. Signed-off-by: FX Coudert <fxcoudert@gmail.com>

view details

BrewTestBot

commit sha 58fb526353c223f2befafdebf559f5b712470948

mesa: update 18.3.4 bottle.

view details

Roberto Salas

commit sha 7711e49a20785182c650644aa1b1bfa9b2575d7e

h3 3.4.2 (new formula) Closes #37174. Signed-off-by: FX Coudert <fxcoudert@gmail.com>

view details

BrewTestBot

commit sha a379bec817d3b4a8d51deb39e67530db98ef11d7

h3: add 3.4.2 bottle.

view details

Schanzenbach, Martin

commit sha 2529d3152d1fa038ac58d2b34040b1936c3afb3e

gnutls: build with unbound/dane support Closes #37005. Signed-off-by: FX Coudert <fxcoudert@gmail.com>

view details

BrewTestBot

commit sha 776efae04d38dfc661051463930a373d4ecc92e0

gnutls: update 3.6.6 bottle.

view details

Misty De Meo

commit sha de68c83e4bfca3a55f80f02f2843cf9045d2cc3f

elasticsearch: make postinstall rerunnable

view details

Misty De Meo

commit sha 68324b22f4de991a8cdaace07e353414ea66cb6a

elasticsearch@2.4: make postinstall rerunnable

view details

Misty De Meo

commit sha b19cfc64634eb839827f283f96acb3b73ea14d6b

elasticsearch 6.6.1

view details

Misty De Meo

commit sha 7d83ee62f954142a906a8926768dd8e08dfa18b6

elasticsearch@5.6: make postinstall rerunnable

view details

Caleb Xu

commit sha 079f78c0cee637fedb4204a4e056a8c18243990f

angular-cli 7.3.3 Closes #37202. Signed-off-by: Misty De Meo <mistydemeo@github.com>

view details

BrewTestBot

commit sha e3e8154d904c6fedd60aae055a0bea6122529c01

angular-cli: update 7.3.3 bottle.

view details

Caleb Xu

commit sha 1759b2d9c1076ee1c1a2d1a3b029ea418188500b

algernon 1.12.3 Closes #37200. Signed-off-by: Misty De Meo <mistydemeo@github.com>

view details

BrewTestBot

commit sha e5b8818f542756c6c69994659db1ff83512193f8

algernon: update 1.12.3 bottle.

view details

Loki Astari

commit sha 63374d9c8461e9d5a017c8a54dd238c7eb86c846

thors-serializer 1.10.2 Closes #37207. Signed-off-by: Misty De Meo <mistydemeo@github.com>

view details

BrewTestBot

commit sha 1c7339c86234b92e73b15072325b5a3ca4d276e2

thors-serializer: update 1.10.2 bottle.

view details

push time in 7 days

pull request commentdenoland/deno

WIP add homebrew file

Re testing, I think it's easier to just make a pr to homebrew-core. I'm not sure how they've configured Jenkins, so previously I just waited to build.

I suspect no sccache, a slow build is ok. Once it's built by homebrew-core it's available as a "bottle" so users are just downloading a binary.

ry

comment created time in 7 days

issue commentdenoland/deno

Return floating point number from performance.now()

Do up have a wip branch/commit? I can do but likely not this week.

luvies

comment created time in 7 days

Pull request review commentdenoland/deno

No prompts flag for non interactive environments.

 pub fn set_flags(   opts.optflag("", "allow-env", "Allow environment access");   opts.optflag("", "allow-run", "Allow running subprocesses");   opts.optflag("A", "allow-all", "Allow all permissions");+  opts.optflag("", "no-prompt", "Do not use prompts");

What other prompts are there?

I don't understand the difference.

afinch7

comment created time in 8 days

pull request commentdenoland/deno

No prompts flag for non interactive environments.

Does atty not already do this?

https://github.com/denoland/deno/blob/77d7ad61f39641b79a60a99da2f939cbc1d8fe39/src/permissions.rs#L152

afinch7

comment created time in 8 days

pull request commentdenoland/deno_std

Use performance.now in benching module

This should wait til https://github.com/denoland/deno/issues/1777. There may be some further tweaks possible after that anyway.

sh7dm

comment created time in 9 days

issue commentdenoland/deno_std

Discussion: run specific test - test.only

One alternative is skip() that raises a SkipTestError which we catch/handle in runTests.

So code would be:

test(function Foo(){
  if (Deno.platform == 'win') { skip() }
  ...
})
bartlomieju

comment created time in 9 days

pull request commentdenoland/deno

changes to accomodate pyenv to have a project specific python2

pipenv might be preferable, and has windows support, see https://stackoverflow.com/a/41573588/1240268

👍 to something like this.

mcarifio

comment created time in 10 days

issue commentdenoland/deno_std

Discussion: run specific test - test.only

There's a filter regex already, having runTests look at a named --filter arg, and passing it as the filter, seems reasonable to me.

bartlomieju

comment created time in 11 days

pull request commentdenoland/deno_std

Use fs.walk rather than git ls-files

I've fixed the no arg case.

The g flag is a little weird, but I'm not sure a better way to do the globbing. Specifically it would be nice to match only on the first part of the regex (as dir might be a common usecase). That said, I think this is okay (most users will use no arg).

hayd

comment created time in 12 days

push eventhayd/deno_std

Andy Hayden

commit sha a86e106d318b126c6e2327d8973495a6f24d8fa1

Match all if no arg is passed

view details

push time in 12 days

pull request commentdenoland/deno_std

Use fs.walk rather than git ls-files

Good point! I guess this also will need doc updating in --fmt.

(when invoked without args, it doesn't format any file.)

That's a bug, I'll fix it so the default is all files as before.

hayd

comment created time in 12 days

Pull request review commentdenoland/deno_std

Use fs.walk rather than git ls-files

 // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // This script formats the given source files. If the files are omitted, it // formats the all files in the repository.-const { args, readAll, lstat, exit, readFile, writeFile } = Deno;-import { xrun } from "./util.ts";+const { args, exit, readFile, writeFile } = Deno;+import { FileInfo } from "deno";

Fixed!

hayd

comment created time in 12 days

push eventhayd/deno_std

Yoshiya Hinosawa

commit sha 395392912d69fe320d74c1f95a27be8e4adc0fa6

Use Deno global var instead of built-in "deno" module (#247)

view details

Andy Hayden

commit sha c7278b9203a571b3aaddd8d3992470e857533ea9

Use fs.walk rather than git ls-files

view details

push time in 12 days

push eventhayd/registry

Andy Hayden

commit sha 6cf62264fc795b2fff755e4577f7fa2d18c5d824

Tests should fail in travis Add back std as /x/std

view details

push time in 12 days

issue commentdenoland/deno

Build creating unnecessary path

It seems like you have to delete that directory explicitly, it doesn't reappear when running test.py subsequently. I'm not sure whether or not I did something wrong to cause this in https://github.com/denoland/deno/pull/1890/files ...

kitsonk

comment created time in 12 days

pull request commentdenoland/deno_std

Use fs.walk rather than git ls-files

@zekth thanks! That was indeed the issue. ✔️

hayd

comment created time in 12 days

push eventhayd/deno_std

Vincent LE GOFF

commit sha e1d5c00279132aa639030c6c6d9b4e308bd4775e

Testing refactor (#240)

view details

Ryan Dahl

commit sha 4cf39d4a1420b8153cd78d03d03ef843607ae506

Rename assertEq to assertEquals (#242) After some discussion it was found that assertEquals is more common in JS (vs assertEqual, assertEq) and sounds better in the negated form: assertNotEquals vs assertNE.

view details

Yoshiya Hinosawa

commit sha c67751659c50a3c0be5952e3092de7943aa9fa54

Bump CI to v0.3.2 (#245) replace Deno.platform with Deno.build

view details

Vincent LE GOFF

commit sha 899ab67cea12de812c041bcb5ea9ae7fd300d706

Add assertNotEquals, assertArrayContains (#246)

view details

Andy Hayden

commit sha 90ab05c7fed5f7f1d84b9770bcef2aad9cc7b8bc

Use fs.walk rather than git ls-files

view details

push time in 12 days

push eventhayd/deno_std

Andy Hayden

commit sha 22784dceca78fc0af3c9a7f96ae9ceb47f20b063

fix windows prettier test

view details

push time in 12 days

pull request commentdenoland/registry

Remove std modules from registry

Are tests not running, you'd think this would fail...

hayd

comment created time in 13 days

PR opened denoland/registry

Remove std modules from registry

fixes https://github.com/denoland/registry/issues/70

A very breaking change.

+0 -72

0 comment

1 changed file

pr created time in 13 days

push eventhayd/registry

Andy Hayden

commit sha a1cbf99484a6a10617d53761bf34fc80e0fb594d

Remove std modules from registry fixes https://github.com/denoland/registry/issues/70 A very breaking change.

view details

push time in 13 days

issue commentdenoland/registry

discussion: deprecate std modules in registry

@ry Should we just rip the band-aid here?

hayd

comment created time in 13 days

pull request commentdenoland/deno_std

Use fs.walk rather than git ls-files

This windows issue is peculiar, it seems like there's an additional (?) / in there somehow.

hayd

comment created time in 13 days

push eventhayd/deno_std

Andy Hayden

commit sha 0c11cc333459a306f789ab2410455ff02b45d195

lint

view details

push time in 13 days

PR opened denoland/deno_std

Use fs.walk rather than git ls-files
+29 -57

0 comment

2 changed files

pr created time in 13 days

push eventhayd/deno_std

Vincent LE GOFF

commit sha c734e3234322cea5298a887373fe4ad1591d7c97

Refactor asserts in testing (#227)

view details

Evan Hahn

commit sha d430a241244c8b7af57c9b0c22664425987c86a8

Update mime-db to 1.38.0 (#238) mime-db@1.38.0 was released on 2019-02-04. This updates the JSON file.

view details

Andy Hayden

commit sha 0fc13fffbdb59d6aee2b11ff17a5de382273126b

Replace deno.land/x/ with deno.land/std/ (#239)

view details

Andy Hayden

commit sha bc419496190f9d4e6ef8f277147bdcec4a43ab83

Use fs.walk rather than git ls-files

view details

push time in 13 days

create barnchhayd/deno_std

branch : prettier_walk

created branch time in 13 days

issue openedhayd/deno-collections

Fix windows test on azure pipelines

I am getting an error on Windows: https://dev.azure.com/hayd/deno-collections/_build/results?buildId=1

Then add a README (with the badge).

created time in 14 days

pull request commentdenoland/deno_std

Add Stack and Queue to /collections

collections is now at https://github.com/hayd/deno-collections

I added Deque, DefaultDict and Counter but they could use some improvement. ordered map I don't think is needed since Map is ordered...

hayd

comment created time in 14 days

push eventhayd/deno

Andy Hayden

commit sha 6cda53d8a565902345c0f808441b9ae5eef37a54

fmt

view details

push time in 14 days

PR opened denoland/deno

Replace deno.land/x/std with deno.land/std

xlink https://github.com/denoland/registry/issues/70

+19 -19

0 comment

10 changed files

pr created time in 14 days

create barnchhayd/deno

branch : denoland_std

created branch time in 14 days

PR closed denoland/registry

Add promises

Requires https://github.com/denoland/deno_std/pull/202

+4 -0

0 comment

1 changed file

hayd

pr closed time in 14 days

PR opened denoland/deno_std

Replace deno.land/x/ with deno.land/std/

xlink https://github.com/denoland/registry/issues/70

+27 -27

0 comment

13 changed files

pr created time in 14 days

create barnchhayd/deno_std

branch : slash_std

created branch time in 14 days

PR opened denoland/registry

Add collections

https://github.com/hayd/deno-collections This module is still a WIP.

xlink: https://github.com/denoland/deno_std/pull/207#issuecomment-469385604.

+4 -0

0 comment

1 changed file

pr created time in 14 days

push eventhayd/registry

Andy Hayden

commit sha 135005c12e4d3804046f6981586f16707aa4a87f

Add collections https://github.com/hayd/deno-collections This module is still a WIP. xlink: https://github.com/denoland/deno_std/pull/207#issuecomment-469385604.

view details

push time in 14 days

issue openeddenoland/registry

Deprecate std modules in registry

One of the recent issues was a directory that didn't exist in std (to ../utils.ts), this not have been a concern if using the deno.land/std/ links everywhere rather than deno.land/x/http etc.

This would also adds weight to "this is a std lib module" as you can see it from the domain prefix.

This would be a breaking change...

created time in 14 days

issue commentdenoland/deno

Return floating point number from performance.now()

I think it should link to https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp#Reduced_time_precision

otherwise all that you say sounds good.

luvies

comment created time in 14 days

issue commentdenoland/deno

Return floating point number from performance.now()

@zekth I think Instant is going to be higher precision that system time? I think that means the start Instant is going to be needed on IsolateState.

luvies

comment created time in 14 days

pull request commentdenoland/deno_std

Expose fileServer options and move file_server start to examples

Same error 🤔

hayd

comment created time in 14 days

push eventhayd/deno_std

EnokMan

commit sha f65fda8336e72fe0cc19df2077eae5a00e64d337

Fixed non-standard prefix on importing (#216)

view details

Bartek Iwańczuk

commit sha 817a0fb439ff92cd67da8d4f1dae12a2a08121e1

Add runIfMain method (#215)

view details

Andy Hayden

commit sha e609f0c7cb0e7f5eae11c4f1ab78c01470d04347

Clean up the test failure output (#209)

view details

Ryan Dahl

commit sha d441a7dbf01ed87163dcde4120295c0c796f3f0d

Fix import in http_bench.ts (#217)

view details

Bert Belder

commit sha 6063378a9284a48d42e37b4899f947c5c8bbf0b3

Change `import { x } from "deno"` to `const { x } = Deno` (#218)

view details

Ryan Dahl

commit sha 93e5e0cd143d329f9f8d22fe8ea2b7387c251ff4

Bump CI to v0.3.1 (#220)

view details

Vincent LE GOFF

commit sha 0c3ba838fa7e74a859d2a6dbfec3941a521c7988

Glob integration for the FS walker (#219)

view details

Vincent LE GOFF

commit sha 90871cfca6f44a8cfea19345998359d615002b05

Testing add ansi color support from color module (#223)

view details

Vincent LE GOFF

commit sha ccb452f77580148084e7b2dbcfb52b984e0d740e

fs.walk performance improvement (#221)

view details

Vincent LE GOFF

commit sha 0ba93a9b9522dace0c6a6ae9d824d4b580fcd1e3

fixing readme link + version (#225)

view details

Vincent LE GOFF

commit sha b4fba9fb24f1e968bc92531c3c31662387bd032d

Re-enabling colors after color testing (#226)

view details

Vincent LE GOFF

commit sha facc8ce9d228148353c407869a32cc4295b9a264

Fixing default parameters of runBenchmarks (#229)

view details

Vincent LE GOFF

commit sha e2fd507cfd28fa6f4900668d4a80b78a5e97f01b

Refactoring + Enhance UTs + Enhance doc (#230)

view details

chiefbiiko

commit sha 41bdd096f0b300056c58a04392d109bf11c1ce8e

feat: parallel testing (#224)

view details

Dmitry Sharshakov

commit sha 385f866a545176261806d75184e2ef97fa0d5269

Refactor WebSockets (#173) * Use assert.equal instead of deprecated assertEqual * Replace let with const where possible * Add WebSocketMessage type * Use OpCode in WebSocketFrame * Use const where possible in WS * Separate sha1 tests, use const instead of let

view details

Kitson Kelly

commit sha c0390ade3de4d825423c9f0f5e1aa56ffd509942

Add eslint for linting (#235)

view details

Vincent LE GOFF

commit sha 8fb9f709a67e92634b0be3024dfbc70fb445883c

Use pretty assertEqual in testing (#234)

view details

Andy Hayden

commit sha 62ab58928307b5e6d6906fd37d958aadd436d1e3

Expose fileServer options and move to file_server to examples

view details

push time in 14 days

pull request commentdenoland/deno_std

Add promises

@ry defer is useful (and already used in several projects), as are the others...

Happy to re-land this, but want to know how you want it structured.

should this also be in individual files: promises/deferred.ts promises/timeout.ts promises/delay.ts

hayd

comment created time in 14 days

issue commentdenoland/deno

Install deno with homebrew

Please give it a try! Below is a binary brew formula, though you may want to replace the test from the homebrew-core PR. That said, I think this needs a little tweaking to be a valid cask...

https://gist.github.com/hayd/e6ea4568883d339b1787509cb74d0726

ferried

comment created time in 14 days

issue commentdenoland/deno_std

Discussion: asserts

#227 seems to be resolution of this discussion... ?

ry

comment created time in 14 days

push eventhayd/deno-collections

Andy Hayden

commit sha 6caeed9deb246e31145a985cfb386a47d537702c

Update azure-pipelines.yml for Azure Pipelines

view details

push time in 15 days

push eventhayd/deno-collections

Andy Hayden

commit sha 83edf407a828965cbdd57ab76fbed11119f07b7d

Update azure-pipelines.yml for Azure Pipelines

view details

push time in 15 days

push eventhayd/deno-collections

Andy Hayden

commit sha 337fd6f485d78ab2190ff2be5f7681e9291d3411

Initial commit

view details

push time in 15 days

create barnchhayd/deno-collections

branch : master

created branch time in 15 days

created repositoryhayd/deno-collections

created time in 15 days

pull request commentdenoland/deno_std

Expose fileServer options and move file_server start to examples

@ry http/file_server_test.ts tests against examples/file_server.ts.

I'll rebase and see if it's still showing the same Connection refused error on linux...

hayd

comment created time in 15 days

Pull request review commentdenoland/deno_std

WIP: Switching from assert equal to pretty assert equal

 Object.assign(assertions.assert, assertions);  export const assert = assertions.assert as Assert; -/**- * An alias to assert.equal- * @deprecated

But shouldn't this also do assert.equal = prettyAssert?

zekth

comment created time in 15 days

Pull request review commentdenoland/deno_std

WIP: Switching from assert equal to pretty assert equal

 Object.assign(assertions.assert, assertions);  export const assert = assertions.assert as Assert; -/**- * An alias to assert.equal- * @deprecated

Shouldn't assert.equal = prettyAssert and assertEqual be removed?

Or at least, still be deprecated in the doc string.

zekth

comment created time in 15 days

issue commentdenoland/deno_std

YAML support

I think toml is more popular in the rust community.

Personally I find yaml very brittle...

zekth

comment created time in 15 days

issue commentdenoland/deno

Return floating point number from performance.now()

I think you want to return (rounded unless --allow-high-precision) int64 nanos in the op. Then performance.now() and hrtime etc. both use this. As you suggest, Instant seems good approach.

luvies

comment created time in 17 days

issue commentdenoland/deno

Performance.ts hrtime

👍 See https://github.com/denoland/deno/issues/1777

zekth

comment created time in 17 days

issue commentdenoland/deno_std

Discussion: run specific test - test.only

Test cli is waiting on import(), would be able glob on filename and test. https://github.com/denoland/deno_std/issues/193

bartlomieju

comment created time in 17 days

issue commentdenoland/deno

Combine Deno.versions and Deno.platform into Deno.build

is injected during build via rollup.

Implementation-wise I get it and os is clearly used in the build, but semantically os is not a build property. Other statement stands too.

ry

comment created time in 17 days

issue commentdenoland/deno

Combine Deno.versions and Deno.platform into Deno.build

I don't think version should hide in build, the current top level version API is really nice.

It also seems like os isn't really a property of the build.

ry

comment created time in 18 days

pull request commentdenoland/deno_std

Glob integration for the FS walker

lgtm

FYI @ry this is direct copy of https://github.com/hayd/deno-globrex (which is a port of globrex, with very minor changes), with a small wrapper in glob.ts... and a pretty wild RegExp fix to walk.

Once we have this in std we can use globs in --fmt and --test (and other cli apps).

zekth

comment created time in 18 days

pull request commentdenoland/deno_std

fs.walk performance improvement

lgtm 👍

zekth

comment created time in 18 days

Pull request review commentdenoland/deno_std

WIP: Glob integration for the FS walker

+// This file is ported from globrex@0.1.2

also same for globrex_test.ts

Perhaps also needs original license:

// MIT License
// Copyright (c) 2018 Terkel Gjervig Nielsen
zekth

comment created time in 18 days

Pull request review commentdenoland/deno_std

WIP: Glob integration for the FS walker

 function include(f: FileInfo, options: WalkOptions): Boolean {   if (options.exts && !options.exts.some(ext => f.path.endsWith(ext))) {     return false;   }-  if (options.match && !options.match.some(pattern => pattern.test(f.path))) {+  if (+    options.match &&+    !options.match.some(pattern => {

probably need this for skip too. may be worth putting into function:

some(patterns, path) = ...

should also have a comment, and perhaps link to SO, as this is a very surprising thing to have to do.

zekth

comment created time in 18 days

issue commentdenoland/deno

Capabilities of process

I still think permissions = { allow_write: true, allow_env: false, ... } would be nice to have.

zekth

comment created time in 18 days

pull request commentdenoland/deno_std

fs.walk performance improvement

iterating backwards it makes no difference, it's pulling it out of the conditional. walk should iterate forwards.

zekth

comment created time in 18 days

pull request commentdenoland/deno_std

fs.walk performance improvement

wild.

you can also pull out the length lookup:

const length = t.length
for (let i = 0; i < length; i++) {
  let f = t[i];
  if (true) {
    continue;
  }
}

so we're still iterating forward.

zekth

comment created time in 18 days

issue commentdenoland/

Capabilities of process

Sorry, I was just arguing that it should be the above. Not sure if it's already exposed.

zekth

comment created time in 18 days

issue commentdenoland/

Capabilities of process

Sorry, I was just arguing that it should be the above. Not sure if it's already exposed.

zekth

comment created time in 18 days

issue commentdenoland/

Capabilities of process

process.permissions = { allow_write: true, allow_env: false, ... }

zekth

comment created time in 18 days

issue commentdenoland/

Capabilities of process

process.permissions = { allow_write: true, allow_env: false, ... }

zekth

comment created time in 18 days

issue commentdenoland/deno

Per-import permissions?

You can "walk back" --allow-write by having an optional value that restricts access to dirs. This is discussed quite a bit in the other issue.

Some things you can't protect against however, for example if you have --allow-run you're pretty much going to be able to run anything... (Perhaps you could similarly restrict, say only run "git", but still you're still by definition breaking out of the deno permissions).

natevw

comment created time in 18 days

Pull request review commentdenoland/deno_std

WIP: Glob integration for the FS walker

+const { mkdir, open } = Deno;+import { FileInfo } from "deno";+import { test, assert } from "../testing/mod.ts";+import { glob } from "./glob.ts";+import { join } from "./path.ts";+import { testWalk } from "./walk_test.ts";+import { walk, walkSync, WalkOptions } from "./walk.ts";++async function touch(path: string): Promise<void> {+  await open(path, "w");+}++async function walkArray(+  dirname: string = ".",+  options: WalkOptions = {}+): Promise<Array<string>> {+  const arr: string[] = [];+  for await (const f of walk(dirname, { ...options })) {+    arr.push(f.path.replace(/\\/g, "/"));+  }+  arr.sort();+  const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) =>+    f.path.replace(/\\/g, "/")+  ).sort();+  assert.equal(arr, arr_sync);+  return arr;+}++test({+  name: "glob: glob to regex",+  fn() {+    assert.equal(glob("unicorn.*")[0] instanceof RegExp, true);+    assert.equal(glob("unicorn.*")[0].test("poney.ts"), false);+    assert.equal(glob("unicorn.*")[0].test("unicorn.py"), true);+    assert.equal(glob("*.ts")[0].test("poney.ts"), true);+    assert.equal(glob("*.ts")[0].test("unicorn.js"), false);+    assert.equal(+      glob(join("unicorn", "**", "cathedral.ts"))[0].test(+        join("unicorn", "in", "the", "cathedral.ts")+      ),+      true+    );+    assert.equal(+      glob(join("unicorn", "**", "cathedral.ts"))[0].test(+        join("unicorn", "in", "the", "kitchen.ts")+      ),+      false+    );+    assert.equal(+      glob(join("unicorn", "**", "bathroom.*"))[0].test(+        join("unicorn", "sleeping", "in", "bathroom.py")+      ),+      true+    );+    assert.equal(+      glob(join("unicorn", "!(sleeping)", "bathroom.ts"), {+        extended: true+      })[0].test(join("unicorn", "flying", "bathroom.ts")),+      true+    );+    assert.equal(+      glob(join("unicorn", "(!sleeping)", "bathroom.ts"), {+        extended: true+      })[0].test(join("unicorn", "sleeping", "bathroom.ts")),+      false+    );+  }+});++testWalk(+  async (d: string) => {+    await mkdir(d + "/a");+    await touch(d + "/a/x.ts");+  },+  async function globInWalk() {+    const arr = await walkArray(".", { match: glob("*.ts") });+    assert.equal(arr.length, 1);+    assert.equal(arr[0], "./a/x.ts");+  }+);++testWalk(+  async (d: string) => {+    await mkdir(d + "/a");+    await mkdir(d + "/b");+    await touch(d + "/a/x.ts");+    await touch(d + "/b/z.ts");+    await touch(d + "/b/z.js");+  },+  async function globInWalkWildcardFiles() {+    const arr = await walkArray(".", { match: glob("*.ts") });+    assert.equal(arr.length, 2);+    assert.equal(arr[0], "./a/x.ts");+    assert.equal(arr[1], "./b/z.ts");+  }+);++testWalk(+  async (d: string) => {+    await mkdir(d + "/a");+    await mkdir(d + "/a/yo");+    await touch(d + "/a/yo/x.ts");+  },+  async function globInWalkFolderWildcard() {+    const arr = await walkArray(".", {+      match: glob(join( "a", "**", "*.ts"), { flags:'g', extended:true, globstar: true })+    });+    assert.equal(arr.length, 1);+    assert.equal(arr[0], "./a/yo/x.ts");+  }+);++testWalk(+  async (d: string) => {+    await touch(d + "x.ts");

This is like Hitchhiker's Guide to the Galaxy API design here. "That pitfall that you fell in has been perfectly documented in the spec for several years, if you had only bothered to check"

very cool!

Not sure whether that's best way to fix, or if should use the lastIndex reset after each use.

zekth

comment created time in 19 days

Pull request review commentdenoland/deno_std

WIP: Glob integration for the FS walker

+const { mkdir, open } = Deno;+import { FileInfo } from "deno";+import { test, assert } from "../testing/mod.ts";+import { glob } from "./glob.ts";+import { join } from "./path.ts";+import { testWalk } from "./walk_test.ts";+import { walk, walkSync, WalkOptions } from "./walk.ts";++async function touch(path: string): Promise<void> {+  await open(path, "w");+}++async function walkArray(+  dirname: string = ".",+  options: WalkOptions = {}+): Promise<Array<string>> {+  const arr: string[] = [];+  for await (const f of walk(dirname, { ...options })) {+    arr.push(f.path.replace(/\\/g, "/"));+  }+  arr.sort();+  const arr_sync = Array.from(walkSync(dirname, options), (f: FileInfo) =>+    f.path.replace(/\\/g, "/")+  ).sort();+  assert.equal(arr, arr_sync);+  return arr;+}++test({+  name: "glob: glob to regex",+  fn() {+    assert.equal(glob("unicorn.*")[0] instanceof RegExp, true);+    assert.equal(glob("unicorn.*")[0].test("poney.ts"), false);+    assert.equal(glob("unicorn.*")[0].test("unicorn.py"), true);+    assert.equal(glob("*.ts")[0].test("poney.ts"), true);+    assert.equal(glob("*.ts")[0].test("unicorn.js"), false);+    assert.equal(+      glob(join("unicorn", "**", "cathedral.ts"))[0].test(+        join("unicorn", "in", "the", "cathedral.ts")+      ),+      true+    );+    assert.equal(+      glob(join("unicorn", "**", "cathedral.ts"))[0].test(+        join("unicorn", "in", "the", "kitchen.ts")+      ),+      false+    );+    assert.equal(+      glob(join("unicorn", "**", "bathroom.*"))[0].test(+        join("unicorn", "sleeping", "in", "bathroom.py")+      ),+      true+    );+    assert.equal(+      glob(join("unicorn", "!(sleeping)", "bathroom.ts"), {+        extended: true+      })[0].test(join("unicorn", "flying", "bathroom.ts")),+      true+    );+    assert.equal(+      glob(join("unicorn", "(!sleeping)", "bathroom.ts"), {+        extended: true+      })[0].test(join("unicorn", "sleeping", "bathroom.ts")),+      false+    );+  }+});++testWalk(+  async (d: string) => {+    await mkdir(d + "/a");+    await touch(d + "/a/x.ts");+  },+  async function globInWalk() {+    const arr = await walkArray(".", { match: glob("*.ts") });+    assert.equal(arr.length, 1);+    assert.equal(arr[0], "./a/x.ts");+  }+);++testWalk(+  async (d: string) => {+    await mkdir(d + "/a");+    await mkdir(d + "/b");+    await touch(d + "/a/x.ts");+    await touch(d + "/b/z.ts");+    await touch(d + "/b/z.js");+  },+  async function globInWalkWildcardFiles() {+    const arr = await walkArray(".", { match: glob("*.ts") });+    assert.equal(arr.length, 2);+    assert.equal(arr[0], "./a/x.ts");+    assert.equal(arr[1], "./b/z.ts");+  }+);++testWalk(+  async (d: string) => {+    await mkdir(d + "/a");+    await mkdir(d + "/a/yo");+    await touch(d + "/a/yo/x.ts");+  },+  async function globInWalkFolderWildcard() {+    const arr = await walkArray(".", {+      match: glob(join( "a", "**", "*.ts"), { flags:'g', extended:true, globstar: true })+    });+    assert.equal(arr.length, 1);+    assert.equal(arr[0], "./a/yo/x.ts");+  }+);++testWalk(+  async (d: string) => {+    await touch(d + "x.ts");

Is the pattern somehow mutable? I get these being different!!

  const a = options.match && (!options.match.some(pattern => pattern.test(path)));
  const b = options.match && (!options.match.some(pattern => pattern.test(path)));
  const c = options.match && (!options.match.some(pattern => pattern.test(path)));
  console.log(a, b, c)
zekth

comment created time in 19 days

more