Last active
August 18, 2016 21:10
-
-
Save jashkenas/c71021bba8ee580ded92 to your computer and use it in GitHub Desktop.
A little script to publish a "semantic" version of any npm package that uses real version numbers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env coffee | |
fs = require 'fs' | |
sh = require 'execSync' | |
config = JSON.parse fs.readFileSync 'package.json' | |
fs.renameSync 'package.json', 'package.json.real' | |
name = config.name = "#{config.name}-semver" | |
version = config.version = config.version.replace(/\./g, '') + '.0.0' | |
fs.writeFileSync 'package.json', JSON.stringify config, null, 2 | |
sh.run 'npm publish .' | |
sh.run "npm tag #{name}@#{version} stable" | |
fs.unlinkSync 'package.json' | |
fs.renameSync 'package.json.real', 'package.json' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kballenegger no. Should be LPAD. Otherwise, 1.10.0 and 1.1.0 are the same.