BVB Source Codes

reactide Show delete-directory.js Source code

Return Download reactide: download delete-directory.js Source code - Download reactide Source code - Type:.js
  1. 'use strict'
  2.  
  3. const fs = require('fs');
  4. const path = require('path');
  5.  
  6. module.exports = (filePath) => {
  7.   try {
  8.     fs.accessSync(filePath);
  9.     recursivelyDelete(filePath);
  10.   } catch (e) {
  11.     return;
  12.   }
  13.  
  14.   function recursivelyDelete(filePath) {
  15.     //check if directory or file
  16.     let stats = fs.statSync(filePath);
  17.     //if file unlinkSync
  18.     if (stats.isFile()) {
  19.       fs.unlinkSync(filePath);
  20.     }
  21.     //if directory, readdir and call recursivelyDelete for each file
  22.     else {
  23.       let files = fs.readdirSync(filePath);
  24.       files.forEach((file) => {
  25.         recursivelyDelete(path.join(filePath, file));
  26.       });
  27.       fs.rmdirSync(filePath);
  28.     }
  29.   }
  30. }
downloaddelete-directory.js Source code - Download reactide Source code
Related Source Codes/Software:
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
postal - 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top