{"action":"created","issue":{"url":"https://api.github.com/repos/npm/npm/issues/7206","labels_url":"https://api.github.com/repos/npm/npm/issues/7206/labels{/name}","comments_url":"https://api.github.com/repos/npm/npm/issues/7206/comments","events_url":"https://api.github.com/repos/npm/npm/issues/7206/events","html_url":"https://github.com/npm/npm/issues/7206","id":55396199,"number":7206,"title":"Set alias shorthand for scripts and config","user":{"login":"cesarandreu","id":656870,"avatar_url":"https://avatars.githubusercontent.com/u/656870?v=3","gravatar_id":"","url":"https://api.github.com/users/cesarandreu","html_url":"https://github.com/cesarandreu","followers_url":"https://api.github.com/users/cesarandreu/followers","following_url":"https://api.github.com/users/cesarandreu/following{/other_user}","gists_url":"https://api.github.com/users/cesarandreu/gists{/gist_id}","starred_url":"https://api.github.com/users/cesarandreu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cesarandreu/subscriptions","organizations_url":"https://api.github.com/users/cesarandreu/orgs","repos_url":"https://api.github.com/users/cesarandreu/repos","events_url":"https://api.github.com/users/cesarandreu/events{/privacy}","received_events_url":"https://api.github.com/users/cesarandreu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-25T04:11:01Z","updated_at":"2015-01-27T23:26:48Z","closed_at":null,"body":"tl;dr: Allow aliasing npm_package_config and npm_package_scripts to something shorter.\r\n\r\n\r\nI've been using npm as script runner for my apps with great success; I'm very happy to get rid of Gulp/Grunt and the complexity they bring along.\r\nHowever, an issue I've been noticing is that referencing configs as npm_package_config_foobar makes it harder to parse what's going on, especially for longer combinations. The information you truly care about is always at the end, but you have a bunch of `npm_package_config_`'s repeated everywhere. \r\n\r\nIt's become more evident as I've started using 6to5-node, which requires you to call scripts directly.\r\nFor example: `6to5-node _mocha test.spec.js` won't work because it'll try to load `./_mocha`. So you have to run `6to5-node node_modules/.bin/_mocha test.spec.js`. But it starts to become a problem when you have a bunch of scripts and you want to reuse different configs. \r\n\r\n\r\nSmall example of the difference that it could make:\r\n\r\n**Currently**\r\n```json\r\n{\r\n  \"config\": {\r\n    \"all_tests\": \"test/**/*.spec.js\",\r\n    \"mocha\": \"node_modules/.bin/_mocha\",\r\n    \"istanbul\": \"node_modules/.bin/istanbul\"\r\n  },\r\n  \"scripts\": {\r\n    \"base\": \"6to5-node --ignore='foo|bar|baz' --experimental --cache\",\r\n    \"test\": \"npm run base -- $npm_package_config_mocha $npm_package_config_all_tests\",\r\n    \"coverage\": \"npm run base -- $npm_package_config_istanbul cover $npm_package_config_mocha $npm_package_config_all_tests\"\r\n  }\r\n}\r\n```\r\n\r\n**Idea/Proposal**\r\n```json\r\n{\r\n  \"config\": {\r\n    \"npm_package_config_alias\": \"c_\",\r\n    \"all_tests\": \"test/**/*.spec.js\",\r\n    \"mocha\": \"node_modules/.bin/_mocha\",\r\n    \"istanbul\": \"node_modules/.bin/istanbul\"\r\n  },\r\n  \"scripts\": {\r\n    \"base\": \"6to5-node --ignore='foo|bar|baz' --experimental --cache\",\r\n    \"test\": \"npm run base -- $c_mocha $c_all_tests\",\r\n    \"coverage\": \"npm run base -- $c_istanbul cover $c_mocha $c_all_tests\"\r\n  }\r\n}\r\n```\r\n\r\nObviously in this example it wouldn't be a problem to just write the paths directly. But as you end up adding multiple test types, production and development environment scripts, build scripts, application-specific scripts, etc. it becomes painful.\r\n\r\nI think this isn't generally an issue for library developers (it seems like most libraries don't require as many scripts). For application development, my experience has been that you end up needing a lot more scripts. \r\n\r\nTo achieve this, a new alias/shorthand/whatever section could be added to package.json or certain values could be defined in config. One potential problem with defining it in config is that it would break if someone set the value to something else, so it should probably be a per-project config.\r\n\r\nIf npm has no interest in this or considers it out of scope of the problems that it tries to address then it could be implemented as a third-party library. I figured I'd ask because npm is already so close to fulfilling my script-runner needs.\r\n"},"comment":{"url":"https://api.github.com/repos/npm/npm/issues/comments/71750804","html_url":"https://github.com/npm/npm/issues/7206#issuecomment-71750804","issue_url":"https://api.github.com/repos/npm/npm/issues/7206","id":71750804,"user":{"login":"smikes","id":5124609,"avatar_url":"https://avatars.githubusercontent.com/u/5124609?v=3","gravatar_id":"","url":"https://api.github.com/users/smikes","html_url":"https://github.com/smikes","followers_url":"https://api.github.com/users/smikes/followers","following_url":"https://api.github.com/users/smikes/following{/other_user}","gists_url":"https://api.github.com/users/smikes/gists{/gist_id}","starred_url":"https://api.github.com/users/smikes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smikes/subscriptions","organizations_url":"https://api.github.com/users/smikes/orgs","repos_url":"https://api.github.com/users/smikes/repos","events_url":"https://api.github.com/users/smikes/events{/privacy}","received_events_url":"https://api.github.com/users/smikes/received_events","type":"User","site_admin":false},"created_at":"2015-01-27T23:26:48Z","updated_at":"2015-01-27T23:26:48Z","body":"/cc @othiym23 as a feature request\r\n\r\nThis sounds interesting... can you implement a proof-of-concept as a small independent module?  It should be possible to write a program that reads the environment and copies all `npm_config_package_<var>` variables to `<prefix>_<var>`.\r\n\r\nSome other approaches -- \r\n1. You may wish to file an issue with `6to5-node` about searching PATH for the script\r\n2. You could use `which _mocha`, since `./node_modules/.bin` is in your PATH\r\n3. consider using the `#!` hack-around described here: http://sambal.org/2014/02/passing-options-node-shebang-line/"}}