Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// console.log(`Saving file ${filePath}`)
// await fs.mkdir(path.dirname(filePath), {recursive:true})
if (data) {
try {
await jetpack.writeAsync(filePath, data)
return
} catch (error) {
console.error(error)
}
}
if (srcFilePath) {
try {
await jetpack.copyAsync(srcFilePath, filePath, {overwrite : true})
return
} catch (error) {
console.error(error)
}
}
}
const icons = task('icons', async () => {
await jetpack.dirAsync(outputRoot);
const pngGeneration = iconSizes.map(size => {
// https://github.com/lovell/sharp/issues/729
const density = size > 128 ? Math.round(72 * size / 128) : 72;
return sharp(paths.from.icon, { density })
.resize(size, size)
.png()
.toFile(paths.to.icon.png.replace('{size}', size.toString()));
});
return parallel(
jetpack.copyAsync(paths.from.icon, paths.to.icon.svg, { overwrite: true }),
...pngGeneration
) as unknown as Promise;
}, {
timeout: 5000,
async function migrate() {
const olderAppName = 'Rocket.Chat+';
const dirName = process.env.NODE_ENV === 'production' ? olderAppName : `${ olderAppName } (${ process.env.NODE_ENV })`;
const olderUserDataPath = path.join(app.getPath('appData'), dirName);
try {
await jetpack.copyAsync(olderUserDataPath, app.getPath('userData'), { overwrite: true });
await jetpack.removeAsync(olderUserDataPath);
} catch (error) {
if (jetpack.exists(olderUserDataPath)) {
throw error;
}
console.log('No data to migrate.');
}
}
gulp.task('electronStarterCopy', ['inject'], function () {
projectDir.copyAsync('package.json', projectDir.path('build/app') + '/package.json', { overwrite: true });
return gulp.src([
config.appElectronFile
])
.pipe(gulp.dest(config.buildDir));
});
task('css', () => jetpack.copyAsync('css', 'dist', { overwrite: true }), { inputs: ['css/*.*'] });
const css = task('css', () => jetpack.copyAsync('css', 'dist', { overwrite: true }), { watch: ['css/*.*'] });
.then(() => {
jetpack.copyAsync(captureOptions.file, destinationFile)
.then(() => {
jetpack.remove(captureOptions.file);
res.status(HTTP_STATUS_CODE.SUCCESS.CREATED).send();
next();
})
.catch((e) => {
logger('live').error(`Could not copy pcap file: ${e}`);
res.status(HTTP_STATUS_CODE.CLIENT_ERROR.BAD_REQUEST).send(API_ERRORS.UNEXPECTED_ERROR);
});
})
.catch(e => {
const doInstallSpellCheckingDictionaries = function* ({ payload: filePaths }) {
const { spellchecking: { dictionaryInstallationDirectory } } = yield select();
for (const filePath of filePaths) {
const dictionary = path.basename(filePath, path.extname(filePath));
const basename = path.basename(filePath);
const newPath = path.join(dictionaryInstallationDirectory, basename);
try {
yield jetpack.copyAsync(filePath, newPath);
yield put(spellCheckingDictionaryInstalled(dictionary));
} catch (error) {
yield put(spellCheckingDictionaryInstallFailed(dictionary, error));
}
}
};
const copyTask = (browser) => jetpack.copyAsync('src/extension', `build/${browser}`, {
overwrite: true,
matching: [
'./background/background.html',
'./bookmark/popup.html',
'./images/**/*.{png,jpg,gif}',
]
});
await Promise.all(filePaths.map(async (filePath) => {
const name = filePath.basename(filePath, filePath.extname(filePath));
const basename = filePath.basename(filePath);
const newPath = filePath.join(this.dictionariesPath, basename);
await jetpack.copyAsync(filePath, newPath);
if (!this.dictionaries.includes(name)) {
this.dictionaries.push(name);
}
}));
}