@revoloo/cypress6
Version:
Cypress.io end to end testing tool
21 lines (18 loc) • 524 B
JavaScript
const { fs } = require('./fs')
const os = require('os')
const path = require('path')
const trash = require('trash')
const Promise = require('bluebird')
module.exports = {
folder (pathToFolder) {
return fs.statAsync(pathToFolder)
.then(() => {
if (os.platform() === 'linux') {
return fs.emptyDir(pathToFolder)
}
return Promise.map(fs.readdirAsync(pathToFolder), (item) => {
return trash([path.join(pathToFolder, item)])
})
}).catch({ code: 'ENOENT' }, () => {})
},
}