const-version
A tiny command line tool that extract `package.json` version and generate `export const VERSION='...'` file in ES6 syntax
Last updated a year ago by chr.vadala .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install const-version 
SYNC missed versions from official npm registry.

const-version

A tiny command line tool that extract package.json version and generate export const VERSION='...' file in ES6 syntax

Build Status Donate

Usage package.json

{
  "name": "yourproject",
  "version": "1.0.0",
  "scripts": {
    "version": "const-version ./package.json ./src/version.json && git add -A src/version.js"
  }
}

Generated file

    // THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
    export const VERSION = '1.0.0';

Why to use this and avoid import {version} from './package.json' ?

When you use some build tool like webpack, grunt, gulp,... if you do a direct package.json import you will include the content of this file into your bundle. It's not usually good, because:

  • you might share some private data
  • you increase the size of your bundle

This tiny lib exists to avoid this.

Changelog

  • v1.0 - First release
  • v2.0 - Change some dependencies

Contributing

Your contributions (issues and pull request) are very appreciated!

Author

License

MIT

Current Tags

  • 2.0.0                                ...           latest (a year ago)

5 Versions

  • 2.0.0                                ...           a year ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 13
Last Day 0
Last Week 4
Last Month 3
Dependencies (2)
Dev Dependencies (4)

Copyright 2014 - 2016 © taobao.org |