Skip to content

Commit

Permalink
Started adding support for task skipping and task defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
mosen committed Mar 12, 2012
1 parent edf74e5 commit ae894ac
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 33 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,7 @@
v0.0.3
------
+ Initial release

v0.0.4
------
+ Skip tasks is now an array instead of an object literal, and takes the names of the tasks to skip in the queue.
8 changes: 8 additions & 0 deletions bin/cli.js
Expand Up @@ -83,6 +83,14 @@ function build(component) {
logger: logger
};

if (component.skip.length > 0) {
queueOpts.skip = component.skip;
}

if (Object.keys(component.tasks).length > 0) {
queueOpts.defaults = component.tasks;
}

taskQueues.push(queues._createSourceQueue(component, queueOpts));

if (component.skinnable) {
Expand Down
26 changes: 23 additions & 3 deletions lib/component.js
Expand Up @@ -28,22 +28,22 @@ var Component = function() {
} else {
try {
var fs = require('fs'),
buildfile, buildspec,
buildfile,
component = Object.create(Component.prototype, ATTRS);

if (arguments[0] !== undefined && path.existsSync(arguments[0])) {
buildfile = fs.readFileSync(arguments[0]);
component._buildSpec = JSON.parse(buildfile);
component._sourceDir = path.dirname(arguments[0]);
} else {
buildspec = default_spec;
throw new TypeError('The build.json file does not exist or was not specified');
}

component._initFileNames();

return component;
} catch (e) {
throw new TypeError('The build spec file was not readable or parseable: ' + arguments[0] + ' Original error: ' + e);
throw new TypeError('The build.json file was not readable or not parseable: ' + arguments[0] + ' Original error: ' + e);
}
}
};
Expand Down Expand Up @@ -290,6 +290,26 @@ var ATTRS = {
return ', { ' + details.join(', ') + ' }';
}
// no setter, use individual detail accessor
},

/**
* @property skip
* @type Array
*/
skip : {
get : function() {
return this._buildSpec.skip || [];
}
},

/**
* @property defaults
* @type Object
*/
tasks : {
get : function() {
return this._buildSpec.tasks || {};
}
}

};
Expand Down
17 changes: 7 additions & 10 deletions lib/default_spec.js
Expand Up @@ -10,22 +10,19 @@
*/
var defaultBuildSpecification = module.exports = {
name : "component",
type : "js",
type : "js", // js | css | lang
version : "@VERSION@",
skip : {
clean : false,
register : false,
lint : false,
logger: false
},
skip : [],
sourceDir : "js",
sourceFiles : ["component.js"],
sourceFiles : ["component.js"], // By default this should be replaced with component name.js
buildDir : "../build",
assetsDir : "assets",
tools : {
tasks : {
template : {
yuivar : "Y",
module_template : "../templates/moduletemplate.handlebars"
module_template : "../templates/moduletemplate.handlebars",
lang_template : "../templates/lang.handlebars",
rollup_template : "../templates/rollup.handlebars"
},
replace : {
regex: '^.*?(?:logger|Y.log).*?(?:;|\\).*;|(?:\r?\n.*?)*?\\).*;).*;?.*?\r?\n',
Expand Down
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name" : "ybuild",
"version" : "0.0.3",
"version" : "0.0.4",
"description" : "YUI module builder",
"keywords" : ["yui", "yuibuild"],
"author" : {
Expand All @@ -19,7 +19,7 @@
"url" : "https://github.com/mosen/ybuild.git"
},
"dependencies" : {
"buildy" : "0.0.5",
"buildy" : "0.0.6",
"nopt" : "1.0.x",
"winston" : "0.5.x",
"pkginfo" : "0.2.x"
Expand Down
28 changes: 10 additions & 18 deletions test/fixtures/build.json
Expand Up @@ -2,34 +2,26 @@
"name" : "component",
"type" : "js",
"version" : "@VERSION@",
"skip" : {
"clean" : false,
"register" : false,
"lint" : false,
"logger" : false
},
"skip" : [
"files"
],
"sourceDir" : "js",
"sourceFiles" : [
"component.js"
"./component.js"
],
"buildDir" : "../build",
"assetsDir" : "assets",
"tools" : {
"jslint" : {
"jslint option" : null
},
"csslint" : {
"csslint option" : null
}
"buildDir" : "./build",
"assetsDir" : "./assets",
"tasks" : {

},
"details" : {
"use" : null,
"use" : null,
"supersedes" : null,
"requires" : ["base"],
"optional" : null,
"after" : null,
"after_map" : {},
"lang" : ["en-US"],
"skinnable" : true
"skinnable" : false
}
}
4 changes: 4 additions & 0 deletions test/fixtures/component.js
@@ -0,0 +1,4 @@
// Test File

var x = 1;
alert(x);
26 changes: 26 additions & 0 deletions test/fixtures/skip/build.json
@@ -0,0 +1,26 @@
{
"name" : "component",
"type" : "js",
"version" : "@VERSION@",
"skip" : [
],
"sourceDir" : "js",
"sourceFiles" : [
"../component.js"
],
"buildDir" : "../build",
"assetsDir" : "../assets",
"tasks" : {

},
"details" : {
"use" : null,
"supersedes" : null,
"requires" : ["base"],
"optional" : null,
"after" : null,
"after_map" : {},
"lang" : ["en-US"],
"skinnable" : false
}
}

0 comments on commit ae894ac

Please sign in to comment.