test case for resolving implicit package names
-
npm install
-
./test
should emit something like the following:project directory: /home/dev moving to /tmp resolved: /tmp/node_modules/material-design-icons/index.js
test case for resolving implicit package names
npm install
./test
should emit something like the following:
project directory: /home/dev
moving to /tmp
resolved: /tmp/node_modules/material-design-icons/index.js
let projectRoot = process.argv[2]; | |
let path = require.resolve("material-design-icons", { paths: [projectRoot] }); | |
console.log("resolved:", path); |
{ | |
"dependencies": { | |
"material-design-icons": "^3.0.1" | |
} | |
} |
#!/usr/bin/env bash | |
set -eu | |
root_dir=`dirname $0` | |
root_dir=`node -r fs -p "fs.realpathSync(process.argv[1]);" "$root_dir"` | |
filepath="$root_dir/index.js" | |
alt_dir="/tmp" | |
echo "project directory: $root_dir" | |
echo "moving to $alt_dir" | |
cd "$alt_dir" | |
node "$filepath" "$root_dir" |