Skip to content

Instantly share code, notes, and snippets.

@commuterjoy
Last active August 29, 2015 14:01
Show Gist options
  • Save commuterjoy/16ce8733a737c2a771e3 to your computer and use it in GitHub Desktop.
Save commuterjoy/16ce8733a737c2a771e3 to your computer and use it in GitHub Desktop.
Packaging a Express application
/*
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
Copy link

var package = require('./package.json');
var dependencies = package.dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment