Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[feature] more in linke with npm configs

  • Loading branch information...
commit 25b2810131fd1f76caf2f7a9b8e6ec1161f06b08 1 parent f2902da
Bradley Meck authored
3  Readme.md
View
@@ -9,7 +9,8 @@
## CONFIG
-TODO
+--userconfig
+--globalconfig
## ENV SCAFFOLDING
19 bin/nam
View
@@ -18,8 +18,23 @@ var path = require('path');
var NodeApplicationManager = require('../').NodeApplicationManager;
var scaffold = new NodeApplicationManager();
-scaffold.config = require('nconf').argv().env();
-scaffold.config.file(scaffold.config.get('config') || scaffold.config.get('c') || 'config.json');
+scaffold.config = require('nconf').use('memory').argv().defaults({
+ userconfig: path.join(process.env.HOME, '.namconf'),
+ globalconfig: path.join(process.config.variables.node_prefix, '/etc/namconf'),
+ task: {
+ run: {
+ user: 'nobody'
+ }
+ }
+});
+Object.keys(process.env).forEach(function (key) {
+ var conf_pattern = /^nam_config_/;
+ if (conf_pattern.test(key)) {
+ scaffold.config.set(key.replace(conf_pattern, '').replace(/[^0-9A-Za-z]/,':'), process.env[key]);
+ }
+});
+scaffold.config.add('userconfig', {type: 'file', file: scaffold.config.get('userconfig')});
+scaffold.config.add('globalconfig', {type: 'file', file: scaffold.config.get('globalconfig')});
var chdir = scaffold.config.get('cwd') || scaffold.config.get('C');
if (scaffold.config.get('cwd')) {
26 integrations/config.js
View
@@ -0,0 +1,26 @@
+//
+// Add `grunt` task with basic options
+// Should npm install first due to peerDeps possibilities
+//
+exports.name = 'grunt';
+exports.tasks = {
+ config: function (args, options, cb) {
+ if (!args) {
+ cb(new Error('config operation required'));
+ }
+ var operation = args.shift();
+ var key = null;
+ var value;
+ switch (operation) {
+ case 'get':
+ key = args.shift();
+ case 'list':
+ console.dir(this.config.get(key));
+ break;
+ default:
+ cb(new Error('unknown config operation '+JSON.stringify(operation)))
+ return;
+ }
+ cb(null);
+ }
+}
1  integrations/run.js
View
@@ -6,7 +6,6 @@ var path = require('path');
exports.name = 'run';
exports.tasks = {
run: function (args, options, cb) {
- console.log(arguments)
var scaffold = this;
var cmd = args.shift();
var env = options.env || {};
8 integrations/security.js
View
@@ -35,8 +35,8 @@ exports.actions = {
next(null, scaffold, options);
return;
}
- var uid = options.config.get('uid') || process.getuid();
- var gid = options.config.get('gid') || process.getgid();
+ var uid = options.config.get('user') || process.getuid();
+ var gid = options.config.get('group') || process.getgid();
uidNumber(uid, gid, function (err, uid, gid) {
if (err) {
next(err);
@@ -57,8 +57,8 @@ exports.actions = {
return;
}
var scaffold = this;
- var uid = options.config.get('uid');
- var gid = options.config.get('gid');
+ var uid = options.config.get('user');
+ var gid = options.config.get('group');
function setids(err, uid, gid) {
if (err) {
next(err);
2  lib/nam.js
View
@@ -19,7 +19,7 @@ function NodeApplicationManager(options) {
tmpdir: './tmp'
});
this.tasks = {};
- options.builtins = options.builtins || [require('../integrations/run')];
+ options.builtins = options.builtins || [require('../integrations/security'),require('../integrations/config'),require('../integrations/run')];
options.builtins.forEach(this.integrate.bind(this))
return this;
}
Please sign in to comment.
Something went wrong with that request. Please try again.