Skip to content

Instantly share code, notes, and snippets.

@FND
Last active January 15, 2020 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FND/b38d47b3ea20ce1aa1a7060b022a4322 to your computer and use it in GitHub Desktop.
Save FND/b38d47b3ea20ce1aa1a7060b022a4322 to your computer and use it in GitHub Desktop.
test case for resolving implicit package names

test case for resolving implicit package names

  1. npm install

  2. ./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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment