Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, function (err) {
var end = + new Date();
if (err) {
self.updateBuildData({ end: end, status: 1, error: { output: err } });
self.updateProjectStatus(1);
// Send email (if config'd)
var mailer = new Mailer({ project: self.project_name, build: self.build });
// Cleanup
fsx.remove(self.temp);
} else {
// Log end of build
self.updateBuildData({ end: end, status: 0 });
self.updateProjectStatus(0);
// Copy to build folder
fsx.copy(self.temp, __dirname+'/../builds/'+self.project_name, function (err) {
if (err) {
console.log('Error moving completed build of '+self.project_name);
}
// Cleanup
fsx.remove(self.temp);
});
}
});
};
const currentCaches = fs.readdirSync(cacheFolder);
if (!Array.isArray(currentCaches)) {
console.warn('Failed to read the icon cache');
return;
}
const deleteCachePromises: Promise[] = [];
for (const cache of currentCaches) {
// skip hidden folders
if (cache.startsWith('.')) {
continue;
}
// delete
if (!(cache in cacheKeys)) {
deleteCachePromises.push(fs.remove(path.join(cacheFolder, cache)));
}
}
await Promise.all(deleteCachePromises);
}
fs.lstat(rootPath, err => {
const exists = !(err && err.code === 'ENOENT');
if (exists && err) {
return cb.error(err);
}
if (exists && !options.force) {
return cb.alreadyExists('Something else already exists at `' + rootPath + '`.');
}
if (exists) {
fs.remove(rootPath, err => {
if (err) {
return cb.error(err);
}
_afterwards_();
});
} else {
_afterwards_();
}
function _afterwards_() {
// Don't actually write the directory if this is a dry run.
if (options.dry) {
return cb.success();
}
path.resolve(DIST_PATH, 'package.json'),
{ overwrite: true },
);
console.log('Install dependencies.');
await spawnAsync('yarn', ['install'], { cwd: DIST_PATH });
console.log('Rebuild native modules.');
await spawnAsync('npx', [
'electron-rebuild',
'-m',
'dist/',
], { cwd: ROOT_PATH });
console.log('Optimize nodegit.');
await remove(path.resolve(DIST_PATH, 'node_modules/nodegit/vendor'));
console.log('Remove yarn.lock');
await remove(path.resolve(DIST_PATH, 'yarn.lock'));
console.log('Prune node modules.');
await spawnAsync('npm', ['prune', '--production'], { cwd: DIST_PATH });
}
async removeDir(dir) {
try {
await fs.remove(dir);
} catch (err) {
console.error(err);
}
}
await Promise.all(state.executors.map(e => e.wrapper.stop()));
await Promise.all(
state.executors.map(e => new Promise(resolve => e.logStream?.end(resolve)))
);
state.executors = [];
if (state.gcPromise) {
await state.gcPromise;
}
if (options.deleteResources) {
const { tempDir } = state;
const pattern = new RegExp(`/faast/${uuidv4Pattern}$`);
if (tempDir.match(pattern) && (await pathExists(tempDir))) {
log.info(`Deleting temp dir ${tempDir}`);
await remove(tempDir);
}
}
log.info(`local cleanup done.`);
}
async _cleanUp (state, defaultPath) {
if (state.cloned) await fsEx.remove(state.moved ? state.extensionPath : defaultPath)
}
async function deleteFolder (file) {
await fs.remove(file)
}
private _removeBoilerplatePackage(projectName?: string): Promise {
return fse.remove(path.join(this.app.path, projectName ? projectName : this.app.config.packageJson.name, 'package.json'));
}
public async collect(): Promise {
await this.checkPrerequisites();
await this.createTempDir();
await this.clone();
await this.findRepositories();
const result = await this.crawl();
await fs.remove(this.TMP_DIR);
return this.format(result);
}
}