mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-11 10:29:17 +00:00
add sample projects and their loading
This commit is contained in:
parent
cea9e7b1fb
commit
bea76d8873
@ -1,8 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Steppy = require('Steppy'),
|
var Steppy = require('twostep').Steppy,
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
path = require('path');
|
path = require('path'),
|
||||||
|
_ = require('underscore');
|
||||||
|
|
||||||
function Project(config) {
|
function Project(config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@ -34,7 +35,25 @@ exports.load = function(baseDir, name, callback) {
|
|||||||
exports.validateConfig(config, this.slot());
|
exports.validateConfig(config, this.slot());
|
||||||
},
|
},
|
||||||
function(err, config) {
|
function(err, config) {
|
||||||
this.pass(new Project(confg));
|
this.pass(new Project(config));
|
||||||
|
},
|
||||||
|
callback
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all projects from `baseDir` and returns array of project instances
|
||||||
|
*/
|
||||||
|
exports.loadAll = function(baseDir, callback) {
|
||||||
|
Steppy(
|
||||||
|
function() {
|
||||||
|
fs.readdir(baseDir, this.slot());
|
||||||
|
},
|
||||||
|
function(err, dirs) {
|
||||||
|
var loadGroup = this.makeGroup();
|
||||||
|
_(dirs).each(function(dir) {
|
||||||
|
exports.load(baseDir, dir, loadGroup.slot());
|
||||||
|
});
|
||||||
},
|
},
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
|
12
projects/project1/config.json
Normal file
12
projects/project1/config.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "project1",
|
||||||
|
"scm": {
|
||||||
|
"type": "mercurial",
|
||||||
|
"repository": "./test/repos/mercurial",
|
||||||
|
"rev": "default"
|
||||||
|
},
|
||||||
|
"steps": [
|
||||||
|
{"type": "shell", "cmd": "echo 1 > 1.txt"},
|
||||||
|
{"type": "shell", "cmd": "echo 2 > 2.txt"}
|
||||||
|
]
|
||||||
|
}
|
12
projects/project2/config.json
Normal file
12
projects/project2/config.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"name": "project2",
|
||||||
|
"scm": {
|
||||||
|
"type": "mercurial",
|
||||||
|
"repository": "./test/repos/mercurial",
|
||||||
|
"rev": "1"
|
||||||
|
},
|
||||||
|
"steps": [
|
||||||
|
{"type": "shell", "cmd": "echo 11 > 11.txt"},
|
||||||
|
{"type": "shell", "cmd": "echo 22 > 22.txt"}
|
||||||
|
]
|
||||||
|
}
|
@ -1,5 +1,17 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var _ = require('underscore'),
|
||||||
|
project = require('../lib/project');
|
||||||
|
|
||||||
|
var projects;
|
||||||
|
project.loadAll('projects', function(err, loadedProjects) {
|
||||||
|
if (err) throw err;
|
||||||
|
projects = loadedProjects;
|
||||||
|
console.log('Loaded projects: ', _(projects).map(function(project) {
|
||||||
|
return project.config.name;
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = function(data) {
|
module.exports = function(data) {
|
||||||
var projects = [{
|
var projects = [{
|
||||||
name: 'foo'
|
name: 'foo'
|
||||||
|
Loading…
Reference in New Issue
Block a user