Comparing version 1.3.0 to 1.4.0
var truncate = require('./truncate'); | ||
var _ = require('lodash'); | ||
function getEnvironment(pkg) { | ||
var environment = _.get(pkg, 'spec.environment', {}); | ||
return Object.keys(environment).map(function(key) { | ||
return { key: key, value: environment[key]}; | ||
}); | ||
} | ||
module.exports = function (pkg) { | ||
@@ -7,4 +15,5 @@ return { | ||
username: truncate(pkg.name), | ||
description: pkg.description | ||
description: pkg.description, | ||
environment: getEnvironment(pkg) | ||
}; | ||
}; |
{ | ||
"name": "speculate", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Automatically generates an RPM Spec file for your Node.js project", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -201,2 +201,17 @@ # speculate | ||
### Environment variable | ||
If you need to specify environment variables during startup (NODE_ENV for example) you can specify these inline using the spec.environment property: | ||
```json | ||
{ | ||
"spec": { | ||
"environment": { | ||
"NODE_ENV": "production", | ||
"NODE_INSTANCE": "%i" | ||
} | ||
} | ||
} | ||
``` | ||
### Release Number | ||
@@ -203,0 +218,0 @@ |
@@ -21,2 +21,10 @@ var createServiceFile = require('../lib/service'); | ||
}); | ||
it('includes environment variables from the spec.environment property in package.json', function() { | ||
var pkg = require('./fixtures/my-cool-api-environment'); | ||
var expected = loadFixture('my-cool-api-environment.service'); | ||
var service = createServiceFile(pkg); | ||
assert.equal(service, expected); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
40677
46
637
233