3c0731bf2c
Change-Id: I2cb19d34639ea6af55c693fad7bef8855a0ccba3 Signed-off-by: Henry Castro <hcastro@collabora.com>
40 lines
979 B
JavaScript
40 lines
979 B
JavaScript
/* -*- js-indent-level: 8 -*- */
|
|
/* global require Promise */
|
|
|
|
var fs = require('fs');
|
|
var list = require('./selectorList').list;
|
|
|
|
function copyFile(args) {
|
|
return new Promise(function(resolve) {
|
|
var sourceFile = args.sourceDir + args.fileName;
|
|
var destFileName;
|
|
if (args.destFileName) {
|
|
destFileName = args.destFileName;
|
|
} else {
|
|
destFileName = args.fileName;
|
|
}
|
|
|
|
var destFile = args.destDir + destFileName;
|
|
|
|
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');
|
|
});
|
|
}
|
|
|
|
function getSelectors(args) {
|
|
if (args.mode === 'notebookbar') {
|
|
return list[args.name][0];
|
|
} else {
|
|
return list[args.name][1];
|
|
}
|
|
}
|
|
|
|
module.exports.copyFile = copyFile;
|
|
module.exports.getSelectors = getSelectors;
|