Last active
August 29, 2015 14:01
-
-
Save commuterjoy/16ce8733a737c2a771e3 to your computer and use it in GitHub Desktop.
Packaging a Express application
This file contains hidden or 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
/* | |
Deploying an Express application involves packaging, a) dependent node | |
modules, read from 'package.json', b) and a list of arbitrary other | |
directories required at runtime. | |
Usage: | |
$ tar -cvzf source-0.1.0.tar.gz `node scripts/package.js` | |
*/ | |
var fs = require('fs'), | |
package = fs.readFileSync('package.json', 'utf-8'), | |
dependencies = | |
Object | |
.keys(JSON.parse(package).dependencies) // extract runtime dependencies from package.json | |
.map( | |
function (dependency) { | |
return 'node_modules/' + dependency; // convert them to file system paths | |
}) | |
.concat( // add arbitrary other files/directories to the package | |
[ | |
'ft-frontend-template-map.json', | |
'client', | |
'templates', | |
'static', | |
'server' | |
]) | |
console.log(dependencies.join(' ')); // return a tar friendly string |
kavanagh
commented
Oct 24, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment