I'm looking to integrate my grunt project with TeamCity continuous integration server. I need a way to make the package name that TeamCity generates contain the project's version number, that is found in package.json in the root of the project. I can't seem to find a grunt command that provides this, and am resorting to using grep. Is there an undocumented way of getting a grunt project's version from the command line?
相关问题
- Failed at the electron@1.8.2 postinstall script
- Webpack getting started, import error
- No member named ForceSet
- AWS Elastic BeanStalk nodejs Deployment error
- node local dependency installs as shortcut and nes
相关文章
- @angular-cli install fails with deprecated request
- Create React App not installing, showing an error
- new field false in Package.json
- npm : Postinstall not running in docker
- Babel CLI is extremely slow
- Docker and npm - gyp ERR! not ok
- Is there an npm module to modify a pdf file in nod
- Vscode: error TS2307: Cannot find module 'vsco
So in Grunt you can do something like this:
which will pass the name in package.json to any task, in this case, grunt-asciify.
There is also something that does what you ask with regard to getting the version of the project on the command line, simply run
npm version
in the root of your project, which will return something like this:The last one being the project name and version.
Edit: In regard to your comment, try this:
Edit 2: So I wasn't happy with the Grunt one because of Grunt's verbosity when doing anything. If you want something that will just log the version and nothing else whatsoever, then create a new file called
version.js
or whatever in your root directory next topackage.json
. In that file paste this:And call it with
node version.js
. I like this approach the best because it's faster than the Grunt one and it's also smaller. So, enjoy!