libreoffice-online/cypress_test/plugins/tasks.js
Tamás Zolnai cb9fa14d23 cypress: fix failures caused by dirty test documents.
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>
2020-03-11 19:12:21 +01:00

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;