Skip to content

Instantly share code, notes, and snippets.

@particlebanana
Created June 9, 2016 22:56
Show Gist options
  • Save particlebanana/fa3fb1765aaddf40c9c37dd6e9d5d366 to your computer and use it in GitHub Desktop.
Save particlebanana/fa3fb1765aaddf40c9c37dd6e9d5d366 to your computer and use it in GitHub Desktop.
Script to dynamically build up .npmrc in production
// ╔═╗╦═╗╔═╗╦╔╗╔╔═╗╔╦╗╔═╗╦ ╦ ┌─┐┌─┐┌┬┐ ┌┐┌┌─┐┌┬┐┬─┐┌─┐ ┌─┐┬┬ ┌─┐
// ╠═╝╠╦╝║╣ ║║║║╚═╗ ║ ╠═╣║ ║ └─┐├┤ │ │││├─┘│││├┬┘│ ├┤ ││ ├┤
// ╩ ╩╚═╚═╝╩╝╚╝╚═╝ ╩ ╩ ╩╩═╝╩═╝ └─┘└─┘ ┴ ┘└┘┴ ┴ ┴┴└─└─┘ └ ┴┴─┘└─┘
//
// Used in production to install npm private modules
if(process.env.NODE_ENV !== 'production') {
return;
}
var fs = require('fs');
fs.writeFileSync('.npmrc', '//registry.npmjs.org/:_authToken=${NPM_TOKEN}');
fs.chmodSync('.npmrc', 0600);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment