run-func
run-func copied to clipboard
Add support for `npx`
It would be great if this library worked with not just local modules but also npx.
Steps to Reproduce
npx run-func parse-github-url default https://github.com/magic-akari/page-lifecycle
Current Behavior
% npx run-func parse-github-url default https://github.com/magic-akari/page-lifecycle ✗
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module '/private/tmp/temp/parse-github-url'
Require stack:
- /Users/raine/.npm/_npx/1aedd964be30f5cd/node_modules/run-func/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/Users/raine/.npm/_npx/1aedd964be30f5cd/node_modules/run-func/index.js:15:20)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/raine/.npm/_npx/1aedd964be30f5cd/node_modules/run-func/index.js'
]
}
npm ERR! code 1
npm ERR! path /private/tmp/temp
npm ERR! command failed
npm ERR! command sh -c run-func "parse-github-url" "default" "https://github.com/magic-akari/page-lifecycle"
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/raine/.npm/_logs/2021-02-22T18_12_47_304Z-debug.log
Expected Behavior
Url {
protocol: 'https:',
slashes: true,
auth: null,
host: 'github.com',
port: null,
hostname: 'github.com',
hash: null,
search: null,
query: null,
pathname: 'magic-akari/page-lifecycle',
path: 'magic-akari/page-lifecycle',
href: 'https://github.com/magic-akari/page-lifecycle',
filepath: null,
owner: 'magic-akari',
name: 'page-lifecycle',
repo: 'magic-akari/page-lifecycle',
branch: 'master',
repository: 'magic-akari/page-lifecycle'
}
Modules like parse-github-url should work directly with npx instead. I'll keep this issue open in case of more interest in such functionality
I published initial support for npm modules in V3. They must be installed as dependencies as remote modules are out of scope of run-func.
If i.e. parse-github-url is in dependencies then a script run-func parse-github-url default https://github.com/magic-akari/page-lifecycle should work
btw parse-github-url works directly in npx as it should npx parse-github-url https://github.com/magic-akari/page-lifecycle