motion
Version:
motion - moving development forward
83 lines (61 loc) • 2.42 kB
JavaScript
exports.__esModule = true;
var init = _asyncToGenerator(function* () {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var _ref$once = _ref.once;
var once = _ref$once === undefined ? false : _ref$once;
try {
var inFiles = yield _libFns.glob(_libHelpers.SCRIPTS_GLOB);
var _outFiles = yield _libFns.readdir(_opts2['default']('outDir'));
var outFiles = _outFiles.map(function (file) {
return file.path;
}).filter(function (path) {
return path.slice(-4) !== '.map';
});
// cleanup out dir since last run
var deleted = _libFns._.difference(outFiles, inFiles);
var deletedPaths = deleted.map(function (f) {
return _libFns.p(_opts2['default']('outDir'), f);
});
yield Promise.all(deletedPaths.map(function (f) {
return _libFns.rm(f);
}));
_libFns.log.gulp('deleted', deletedPaths);
_scripts.scripts({ inFiles: inFiles, outFiles: outFiles });
} catch (e) {
_libFns.handleError(e);
}
}
// listen to gulp events
);
exports.init = init;
exports.event = event;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { var callNext = step.bind(null, 'next'); var callThrow = step.bind(null, 'throw'); function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(callNext, callThrow); } } callNext(); }); }; }
var _libFns = require('../lib/fns');
var _opts = require('../opts');
var _opts2 = _interopRequireDefault(_opts);
var _libHelpers = require('./lib/helpers');
var _scripts = require('./scripts');
var _styles = require('./styles');
var _app = require('./app');
var _assets = require('./assets');
var listeners = {};
function event(name, cb) {
listeners[name] = listeners[name] || [];
listeners[name].push(cb);
}
event.run = function (name, file, data) {
return listeners[name] && listeners[name].forEach(function (cb) {
return cb(file, data);
});
};
// exports
exports['default'] = {
init: init,
scripts: _scripts.scripts,
afterBuild: _scripts.afterBuild,
assets: _assets.assets,
app: _app.app,
event: event,
styles: _styles.styles
};