cb9fa14d23
It seems sometimes writeFileSync() method does not actually overwrites the document and some tests loads a test document modified by an other test. Hopefully removal of the file will solve this issue. Change-Id: I2cecfd367acce185eeebbdc4269a73a9d1d2dd5a Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90339 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
22 lines
587 B
JavaScript
22 lines
587 B
JavaScript
/* global require Promise */
|
|
|
|
var fs = require('fs');
|
|
|
|
function copyFile(args) {
|
|
return new Promise(function(resolve) {
|
|
var sourceFile = args.sourceDir + args.fileName;
|
|
var destFile = args.destDir + args.fileName;
|
|
|
|
if (fs.existsSync(sourceFile)) {
|
|
fs.mkdirSync(args.destDir, { recursive: true });
|
|
if (fs.existsSync(destFile)) {
|
|
fs.unlinkSync(destFile);
|
|
}
|
|
fs.writeFileSync(destFile, fs.readFileSync(sourceFile));
|
|
resolve('File ${sourceFile} copied to ${destFile}');
|
|
}
|
|
resolve('File ${sourceFile} does not exist');
|
|
});
|
|
}
|
|
|
|
module.exports.copyFile = copyFile;
|