Permalink
Browse files

Added support for --dynamic-skins to work with loader subcommand

  • Loading branch information...
1 parent c054c0d commit 92e4315c9c8dbe097398698c649bd85ae118b850 @davglass davglass committed Jan 7, 2013
Showing with 34 additions and 4 deletions.
  1. +1 −0 lib/args.js
  2. +33 −4 lib/cmds/loader.js
View
@@ -15,6 +15,7 @@ var nopt = require('nopt'),
watch: Boolean,
quiet: Boolean,
local: Boolean,
+ 'dynamic-skins': Boolean,
t: Number,
c: Number,
x: Array,
View
@@ -20,7 +20,7 @@ var util = require('../util'),
},
mods = {
init: function(options) {
-
+
if (options.parsed.json !== false) {
//TODO I need sugar for this..
//Modify the known to make json a path
@@ -49,15 +49,15 @@ mods = {
this.mix = this.options.parsed.mix || false;
this.strict = this.options.parsed.strict || false;
-
+
this.json = this.options.parsed.json || path.join(this.start, 'loader/js/yui3.json');
this.js = this.options.parsed.js || path.join(this.start, 'loader/js/yui3.js');
this.tests = this.options.parsed.tests || path.join(this.start, 'yui/js/load-tests.js');
this.group = this.options.parsed.group;
-
+
if (this.options.parsed.json === false) {
this.json = false;
}
@@ -117,8 +117,37 @@ mods = {
if (this.group) {
data.group = this.group;
}
+ if (this.options.parsed['dynamic-skins']) {
+ data = this.addSkins(name, data, file);
+ }
this.data.json[name] = this.sortObject(data);
},
+ addSkins: function(name, data, file) {
+ if (data && data.skinnable) {
+ log.info('parsing skins for ' + name);
+ var skins = path.join(this.start, path.dirname(file), '../', 'assets'),
+ dirs;
+
+ if (util.exists(skins)) {
+ if (util.exists(path.join(skins, name))) {
+ skins = path.join(skins, name);
+ }
+ dirs = fs.readdirSync(path.join(skins, 'skins'));
+ dirs.forEach(function(skin) {
+ if (skin.indexOf('.') === 0) {
+ return;
+ }
+ var stat = fs.statSync(path.join(skins, 'skins', skin));
+ if (stat.isDirectory()) {
+ data.skins = data.skins || [];
+ data.skins.push(skin);
+ }
+ });
+ }
+ }
+
+ return data;
+ },
sortObject: function(data) {
var keys = Object.keys(data).sort(),
d = {};
@@ -218,7 +247,7 @@ mods = {
jsonStr = JSON.stringify(out, null, 4);
-
+
if (this.json) {
log.info('writing json: ' + this.json);
mkdirp.sync(path.dirname(this.json));

0 comments on commit 92e4315

Please sign in to comment.