Created
December 13, 2017 03:14
-
-
Save elycruz/3d6397ac531411ed710326f330c5c58c to your computer and use it in GitHub Desktop.
Outputs the version number of an npm package through a readstream.
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
const | |
util = require('util'), | |
stream = require('stream'), | |
Readable = stream.Readable, | |
packageJson = require('../package'); | |
function VersionNumberReadStream (options) { | |
Readable.call(this, Object.assign({ | |
encoding: 'utf8', | |
objectMode: false, | |
}, options)); | |
} | |
util.inherits(VersionNumberReadStream, Readable); | |
VersionNumberReadStream.prototype._read = function () { | |
`/** | |
* Content generated by '{project-root}/build-scripts/VersionNumberReadStream.js'. | |
* Generated ${new Date()} | |
*/ | |
export const version = '${packageJson.version}'; | |
export default version; | |
` | |
.split('').forEach(this.push, this); | |
this.push('\n'); | |
this.push(null); | |
}; | |
module.exports = VersionNumberReadStream; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment