В следующем фрагменте вызов
ifDirectoryExistsNot(folderName + dataType)
заканчивается на
ReferenceError: ifDirectoryExistsNot is not defined
Знаете ли вы, почему это так?
var Folder = {
deleteRecursively: (exportFromCosmosPath) => {
const child_process = require ('child_process')
const dirToRemove = exportFromCosmosPath
const k = child_process.spawn('bash')
k.stdin.end(`rm -rf "${dirToRemove}"`)
k.once('exit', code => {
// check the exit code
// now you are done
})
},
ifDirectoryExists: () => {
fs.existsSync
},
ifDirectoryExistsNot: (folderName, dataType) => {
if (negateFunction(fs.existsSync)){
console.log('creating dir..... ' + folderName + " " + dataType )
fs.ensureDirSync(folderName, dataType)
}
},
negateFunction: () => {
return function(x) {
return !func(x)
}
},
ensureThatDirectoryExists: (folderName, dataType) => {
ifDirectoryExistsNot(folderName + dataType)
}
}
// my Code:
Folder.deleteRecursively('data/*')
Folder.ensureThatDirectoryExists('data/exportFromCosmos/', 'DEFAULT')
Folder.ensureThatDirectoryExists('data/uploadToBlobStorage/', dataType)