Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Use start script #43

Closed
piranna opened this issue Apr 30, 2017 · 13 comments
Closed

Use start script #43

piranna opened this issue Apr 30, 2017 · 13 comments

Comments

@piranna
Copy link

piranna commented Apr 30, 2017

The canonical default executable is start script in the package.json file, that by default is server.js file, not bin entry since you can define several binaries in a single package.

@TooTallNate
Copy link
Member

That is, you'd like to just run pkg without specifying a filename? An interesting idea. The problem with start is that it's an arbitrary shell command, not a JavaScript entry point. The main entry point could perhaps be more appropriate since it does point to a JavaScript file.

@TooTallNate
Copy link
Member

Or some property in the package.pkg config object, like "entrypoint".

@igorklopov
Copy link
Contributor

You can always specify entry point javascript file explicitly in CLI instead of passing path to package.json.

@jimbuck
Copy link

jimbuck commented May 2, 2017

Thoughts on using the main field?

I know it's primarily used in libraries, but it would be a good fit for pkg as well.

@piranna
Copy link
Author

piranna commented May 2, 2017 via email

@igorklopov
Copy link
Contributor

igorklopov commented May 2, 2017

Sorry, i can not get why you don't like bin field. Pkg's purpose is to (mostly) emulate npm i something -g tool installation and usage scenario. Since globally installed tool uses bin field, the idea behind pkg was to use bin field as well.

@igorklopov
Copy link
Contributor

And yeah, you can specify several subfields in bin field. Pkg will use one that's name matches with name field of package.json.

@TooTallNate
Copy link
Member

@igorklopov Ahhh I did not realize that the bin entry was already supported. I see now that it's also documented in the README.

I'm closing since I don't think it makes sense to duplicate functionality when there is already a mechanism to specify entry point in the package.json. Thank you for the suggestion though!

@piranna
Copy link
Author

piranna commented May 2, 2017 via email

@TooTallNate
Copy link
Member

@piranna The "start" script is used for starting servers, not CLI applications. The bin field is absolutely used for CLI applications, and npm encourages this with the --global flag installing into your $PATH.

pkg mapping to bin is perfect.

@piranna
Copy link
Author

piranna commented May 2, 2017

npm start is also used to start cli applications too, I have seen using server.js just for this everywhere. Also, since several years ago usage of --global and globally installed modules are absolutely deprecated, so that's not the point. You can use bin, but that's a mapping of the executables that offer that module, that can be several of them, and there's no requeriment that any of them has the same name of the current module, so blindly trust on that field is a bad usage and a bug according to the spec. As I said before, better alternatives are to use standard start script, or if not following standard practices, add a new custom field on package.json file just for this.

@dotcypress
Copy link

dotcypress commented May 13, 2017

Great idea with npm start 👍

Implementing that allows us easily pack micro-services to single executable.

UPD: As quick fix, it possible to use full path to runner in bin script, works well in my case.
"bin": "node_modules/micro-bot/bin/micro-bot".

@joaodvilla
Copy link

Hello, is it possible to run a global CLI, like "adonis migration: run" from pkg side?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants