UNPKG

motion

Version:

motion - moving development forward

74 lines (47 loc) 2.71 kB
exports.__esModule = true; var init = _asyncToGenerator(function* () { var isDiffVersion = yield differentMotionVersion(); if (_opts2['default']('reset') || isDiffVersion) yield _libFns.recreateDir(_opts2['default']('internalDir')); yield Promise.all([_libFns.recreateDir(_opts2['default']('deps').assetsDir), _libFns.mkdir(_opts2['default']('internalDir')), _libFns.mkdir(_opts2['default']('styleDir')), _libFns.rm(_libFns.p(_opts2['default']('internalDir'), 'user-config'))]); if (_opts2['default']('cached')) yield _libFns.mkdir(_opts2['default']('outDir'));else yield _libFns.recreateDir(_opts2['default']('outDir')); }); exports.init = init; var internalDir = _asyncToGenerator(function* () { _libFns.log(LOG, 'internalDir'); yield _libFns.recreateDir(_opts2['default']('internalDir')); }); exports.internalDir = internalDir; var outDir = _asyncToGenerator(function* () { _libFns.log(LOG, 'outDir'); yield _libFns.recreateDir(_opts2['default']('outDir')); }); exports.outDir = outDir; var styles = _asyncToGenerator(function* () { _libFns.log(LOG, 'outDir'); yield _libFns.recreateDir(_opts2['default']('styleDir')); }); exports.styles = styles; var buildDir = _asyncToGenerator(function* () { _libFns.log(LOG, 'buildDir'); yield _libFns.recreateDir(_opts2['default']('buildDir')); yield _libFns.mkdir(_libFns.p(_opts2['default']('buildDir'), '_')); }); exports.buildDir = buildDir; var differentMotionVersion = _asyncToGenerator(function* () { var version = _opts2['default']('version'); var state = yield _disk2['default'].state.read(); var stateVersion = state && state.opts && state.opts.version; if (!stateVersion) return true; var isDiff = version != stateVersion; if (isDiff) print(' New motion version, updating...\n'.dim); return isDiff; }); 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 _disk = require('../disk'); var _disk2 = _interopRequireDefault(_disk); var LOG = 'clear'; exports['default'] = { init: init, outDir: outDir, buildDir: buildDir, internalDir: internalDir, styles: styles };