mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-02-10 18:49:15 +00:00
add sample projects and their loading
This commit is contained in:
parent
cea9e7b1fb
commit
bea76d8873
@ -1,8 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var Steppy = require('Steppy'),
|
||||
var Steppy = require('twostep').Steppy,
|
||||
fs = require('fs'),
|
||||
path = require('path');
|
||||
path = require('path'),
|
||||
_ = require('underscore');
|
||||
|
||||
function Project(config) {
|
||||
this.config = config;
|
||||
@ -34,7 +35,25 @@ exports.load = function(baseDir, name, callback) {
|
||||
exports.validateConfig(config, this.slot());
|
||||
},
|
||||
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
|
||||
);
|
||||
|
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';
|
||||
|
||||
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) {
|
||||
var projects = [{
|
||||
name: 'foo'
|
||||
|
Loading…
Reference in New Issue
Block a user