Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// parse This
console.info("Resonse from ccu is %s bytes",data.length);
console.info("Rebuilding JSON");
let jData = JSON.parse(data);
let device = jData.devices[0];
if (device!=undefined) {
let adr = device.address;
let dtype = device.type;
device.address = "ADR1234567890";
device.channels.map(function (channel){
channel.address = channel.address.replace(adr,"ADR1234567890");
})
let fileName = path.join(__dirname,'..','test','lib','data','data_test_') + dtype + ".json";
if (fs.existsSync(fileName)) {
console.info("moving old file into trash");
fs.unlink(fileName);
}
var buffer = JSON.stringify(jData,null, 2);
fs.writeFileSync(fileName, buffer);
console.info("written to %s",fileName);
} else {
console.info("No data for %s",program.address)
}
})
}).on('error', function(err) { // Handle errors
fs.unlink(dest); // Delete the file async. (But we don't check the result)
if (cb) cb(err.message);
});
}
}).on('error', function(err) { // Handle errors
fs.unlink(dest); // Delete the file async. (But we don't check the result)
if (cb) cb(err);
});
}
delete iris.configStore[configStoreCategory][configStoreInstance][filename];
} else {
if (iris.configStore[directory]) {
delete iris.configStore[directory][filename];
}
}
var filePath = path.join(iris.sitePath, "/configurations", directory);
filePath = filePath + '/' + filename + '.json';
fs.unlink(filePath, function (err) {
if (err) {
// Return err = true
callback(true);
} else {
callback(false);
}
});
};
linklocal(PKG_DIR, function (err, linked) {
t.ifError(err)
var links = linked.map(getLink).sort()
t.deepEqual(links, LINKS)
fs.unlink(links[0], function (err) {
t.ifError(err)
linklocal.unlink(PKG_DIR, function (err, linked) {
t.ifError(err)
var expected = LINKS.slice(1)
t.deepEqual(linked.map(getLink).sort(), expected)
expected.forEach(function (link) {
t.notOk(fs.existsSync(link))
})
t.end()
})
})
})
})
self.outputFiles.forEach(function(outfile){fs.unlink(outfile.path);});
return self.emit('finish', new Error('CompileStream error. file stream error.'), self._stdout, self._stderr, code);
fs.readFile(file, 'utf-8', function (err, data)
{
fs.unlink(file, function(err2)
{
if (err) throw err;
//if (err2) throw err;
console.log(data.toString());
callback(JSON.parse(data,isoDateReviver));
//callback(eval(data));
});
});
}
.then( () => {
unlink( outfile, ( err: Error ) => {
if(err) console.log( 'failed to clean up test file' )
} )
} )
} )
const cb = err => {
if (err) {
fs.unlink(src, function() {});
}
_cb(err);
};
function deleteAnyExistingFile(cb) {
//on windows, you can get a EEXIST error if you rename a file to an existing file
//so, we'll try to delete the file we're renaming to first
fs.unlink(newFilename, function (err) {
//ignore err: if we could not delete, it's most likely that it doesn't exist
cb();
});
}