glass-platform
Version:
Glass platform
129 lines (107 loc) • 3.39 kB
JavaScript
// Generated by CoffeeScript 1.6.2
(function() {
var browserBuild, build, check, exports, fs, getPackageJson, np, runTest, util, watchCompile, watchTest, watcher;
require('../global');
fs = require('fs');
np = require('path');
util = require('./utility');
watcher = require('./watcher');
browserBuild = require('browser-build');
check = function(config) {
var _base, _base1, _base2, _name, _ref, _ref1, _ref2;
if (config.coffee.input == null) {
throw new Error("config.coffee.input is required");
}
if (config.coffee.output == null) {
throw new Error("config.coffee.output is required");
}
if (config.browser != null) {
if ((_ref = (_base = config.browser).input) == null) {
_base.input = {};
}
if ((_ref1 = (_base1 = config.browser.input)[_name = config.coffee.output]) == null) {
_base1[_name] = config.name;
}
if ((_ref2 = (_base2 = config.browser).output) == null) {
_base2.output = "browser";
}
}
};
build = function(config, callback) {
return util.spawn("coffee.cmd -c -m -o " + config.coffee.output + " " + config.coffee.input, callback);
};
runTest = function(config, callback) {
var list;
list = util.list(config.coffee.output, {
include: ".js"
});
return util.spawn("mocha.cmd --harmony -R spec " + (list.join(' ')), callback);
};
watchCompile = function(config) {
util.spawn("coffee.cmd -w -m -c -o " + config.coffee.output + " " + config.coffee.input);
if (config.browser != null) {
return browserBuild.watch(config.browser);
}
};
watchTest = function(config) {
var debouncedRunTest, options;
debouncedRunTest = (function() {
return runTest(config);
}).debounce(500);
options = {
filter: ".js",
initial: false
};
return watcher.watchDirectory(config.coffee.output, options, debouncedRunTest);
};
getPackageJson = function(config) {
var path;
path = np.join(config.coffee.output, 'package.json');
return JSON.parse(fs.readFileSync(path, 'utf8'));
};
module.exports = exports = {
build: function(config, callback) {
check(config);
return build(config, function() {
if (config.browser != null) {
browserBuild.build(config.browser);
}
return runTest(config, callback);
});
},
watch: function(config) {
var _ref;
check(config);
watchCompile(config);
watchTest(config);
if (((_ref = config.browser) != null ? _ref.port : void 0) != null) {
return util.startWebServer({
root: config.browser.output.directory,
port: config.browser.port
});
}
},
test: function(config, callback) {
check(config);
return runTest(config, callback);
},
publish: function(config) {
return util.spawn("npm.cmd publish " + config.coffee.output);
},
bump: function(config) {
var pj, version;
pj = getPackageJson(config);
version = pj.version.split('.');
version[2] = parseInt(version[2]) + 1;
version = version.join('.');
return util.spawn("npm.cmd version " + version, {
cwd: config.coffee.output
}, function() {
return exports.publish(config);
});
}
};
}).call(this);
/*
//@ sourceMappingURL=index.map
*/