10 examples of 'delete files nodejs' in JavaScript

Every line of 'delete files nodejs' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
57function removeFiles() {
58 return del(paths.dist.baseDir);
59}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

64function copyAndDelFiles() {
65 var copyFile = '';
66
67 // 复制文件
68 if (isDev()) {
69 copyFile = 'src/html/index_dev.html';
70 }
71
72 if (isProd()) {
73 copyFile = 'src/html/index.html';
74 }
75
76 copy(copyFile, 'index.html', function(error) {
77 if (error) {
78 return console.error(error);
79 }
80 });
81
82 if (isProd()) {
83 del(['dist']);
84 }
85}
12function deleteBuildScript() {
13 if (fs.existsSync(BUILD_SCRIPT)) {
14 fs.unlinkSync(BUILD_SCRIPT);
15 }
16
17 if (fs.existsSync(`./${TMP_DIR}`)) {
18 deleteFolderSync(`./${TMP_DIR}`);
19 }
20}
368function myDelete(myDir) {
369 // Custom function to delete project folder, in case a process has it locked on Windows
370 try {
371 shelljs.rm("-rf", myDir);
372 } catch (e) {
373 // The project directory after an Android build and emulation is locked by ADB.EXE (Android Debug Bridge).
374 // Kill the process & restart folder deletion
375 if (/^win/.test(process.platform)) {
376 console.log("Not all files were deleted, killing ADB.EXE process to unlock folder...");
377 executeShellCommand("TASKKILL /F /IM ADB.exe /T");
378 shelljs.rm("-rf", myDir);
379 } else
380 throw new Error("Error during folder deletion, try to remove " + myDir + " manually.");
381 }
382}
29async clean() {
30 const distPath = path_1.default.resolve(process.cwd(), this.distPath);
31 del_1.default.sync([distPath]);
32 return;
33}
44function cleanJs() {
45 return del(['web/js/**', '!web/js', '!web/js/.gitkeep']);
46}
33function remove(file) {
34 fs.removeSync(file);
35}
9function clean(file) {
10 return rimraf(file, (err) => {
11 console.log(`${chalk.yellow('removed:')} ${chalk.grey(file)}`);
12 });
13}
34async cleanup(): Promise<void> {
35 const {out} = this;
36 await fs.unlink(path.join(out, '*'));
37}
215export function deleteFile(arg: DeleteFileOptions): Promise<void> {
216 return new Promise<void>((resolve, reject) => {
217 try {
218
219 const storageRef = getStorageRef(reject, arg);
220
221 if (!storageRef) {
222 return;
223 }
224
225 const storageReference = storageRef.child(arg.remoteFullPath);
226
227 const onSuccessListener = new com.google.android.gms.tasks.OnSuccessListener({
228 onSuccess: () => {
229 resolve();
230 }
231 });
232
233 const onFailureListener = new com.google.android.gms.tasks.OnFailureListener({
234 onFailure: exception => {
235 reject(exception.getMessage());
236 }
237 });
238
239 storageReference.delete()
240 .addOnSuccessListener(onSuccessListener)
241 .addOnFailureListener(onFailureListener);
242
243 } catch (ex) {
244 console.log("Error in firebase.deleteFile: " + ex);
245 reject(ex);
246 }
247 });
248}

Related snippets