3 Commits a33e9fc09a ... 3dff68b58e

Author SHA1 Message Date
  Kyle P Davis 3dff68b58e feat: support modules and files in node-print 5 years ago
  Kyle P Davis c337c8e8f3 feat: add empty file support to node-print 5 years ago
  Kyle P Davis 1270f82d8c feat: resolve async results in node-print 5 years ago
1 changed files with 2 additions and 2 deletions
  1. 2 2
      .profile

+ 2 - 2
.profile

@@ -87,8 +87,8 @@ alias l="ls -FC"
 alias d="l"
 alias tree="tree -CF"
 alias grep="grep --color --exclude-dir={.svn,.git,node_modules}"
-alias node-print="node -p -e 'const [,f=\".\",e=\"this\"]=process.argv; (function(){ with(this) return eval(e); }).call(require(path.resolve(f)))'"
-alias ts-node-print="TS_NODE_FILES=true node -r ts-node/register -p -e 'const [,f=\".\",e=\"this\"]=process.argv; (function(){ with(this) return eval(e); }).call(require(path.resolve(f)))'"
+alias node-print="node -e 'let [,f=\".\",e=\"this\"]=process.argv,ctx; try{ctx=require(f)}catch{ctx=require(path.resolve(f))}; eval(\`(async function(){ with(this) return (\${e}); })\`).call(ctx).then(console.log)'"
+alias ts-node-print="TS_NODE_FILES=true node -r ts-node/register -e 'let [,f=\".\",e=\"this\"]=process.argv,ctx; try{ctx=require(f)}catch{ctx=require(path.resolve(f))} eval(\`(async function(){ with(this) return (\${e}); })\`).call(ctx).then(console.log)'"
 
 # color diffs
 ! command -v colordiff &>/dev/null  ||  alias diff="colordiff"