electron-builder
Version:
A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with “auto update” support out of the box
101 lines (83 loc) • 3.23 kB
JavaScript
;
var _bluebirdLstC;
function _load_bluebirdLstC() {
return _bluebirdLstC = require("bluebird-lst-c");
}
var _bluebirdLstC2;
function _load_bluebirdLstC2() {
return _bluebirdLstC2 = _interopRequireDefault(require("bluebird-lst-c"));
}
let main = (() => {
var _ref = (0, (_bluebirdLstC || _load_bluebirdLstC()).coroutine)(function* () {
const dir = (_path || _load_path()).join((0, (_util || _load_util()).getCacheDirectory)(), "fpm");
let items = null;
try {
items = yield (0, (_fsExtraP || _load_fsExtraP()).readdir)(dir);
} catch (e) {
if (e.code !== "ENOENT") {
throw e;
}
return;
}
yield (_bluebirdLstC2 || _load_bluebirdLstC2()).default.map(items, (() => {
var _ref2 = (0, (_bluebirdLstC || _load_bluebirdLstC()).coroutine)(function* (it) {
let stat = null;
const itemPath = (_path || _load_path()).join(dir, it);
try {
stat = yield (0, (_fsExtraP || _load_fsExtraP()).lstat)(itemPath);
} catch (e) {
if (e.code !== "ENOENT") {
throw e;
}
return;
}
if (!stat.isDirectory() || !(yield isRecentlyUsed(itemPath))) {
console.log(`remove unused ${ itemPath }`);
yield (0, (_fsExtraP || _load_fsExtraP()).remove)(itemPath);
}
});
return function (_x) {
return _ref2.apply(this, arguments);
};
})());
yield (_bluebirdLstC2 || _load_bluebirdLstC2()).default.map(items, (_fsExtraP || _load_fsExtraP()).remove);
});
return function main() {
return _ref.apply(this, arguments);
};
})();
let isRecentlyUsed = (() => {
var _ref3 = (0, (_bluebirdLstC || _load_bluebirdLstC()).coroutine)(function* (dir) {
try {
const lastUsed = parseInt((yield (0, (_fsExtraP || _load_fsExtraP()).readFile)((_path || _load_path()).join(dir, ".lastUsed"), "utf8")), 10);
if (!isNaN(lastUsed) && Date.now() - lastUsed < 3600000 * 2) {
return true;
}
} catch (e) {
if (e.code !== "ENOENT") {
throw e;
}
}
return false;
});
return function isRecentlyUsed(_x2) {
return _ref3.apply(this, arguments);
};
})();
var _fsExtraP;
function _load_fsExtraP() {
return _fsExtraP = require("fs-extra-p");
}
var _path;
function _load_path() {
return _path = _interopRequireWildcard(require("path"));
}
var _util;
function _load_util() {
return _util = require("./util/util");
}
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
main();
//# sourceMappingURL=cleanup.js.map