|
|
|
@ -35,10 +35,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
|
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.plugin = exports.details = void 0;
|
|
|
|
exports.plugin = exports.details = void 0;
|
|
|
|
var fs_1 = require("fs");
|
|
|
|
var fs_1 = require("fs");
|
|
|
|
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
|
|
|
var fileUtils_1 = require("../../../../FlowHelpers/1.0.0/fileUtils");
|
|
|
|
|
|
|
|
var normJoinPath_1 = __importDefault(require("../../../../FlowHelpers/1.0.0/normJoinPath"));
|
|
|
|
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
|
|
|
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
|
|
|
|
var details = function () { return ({
|
|
|
|
var details = function () { return ({
|
|
|
|
name: 'Copy to Directory',
|
|
|
|
name: 'Copy to Directory',
|
|
|
|
@ -56,12 +60,12 @@ var details = function () { return ({
|
|
|
|
type: 'string',
|
|
|
|
type: 'string',
|
|
|
|
defaultValue: '',
|
|
|
|
defaultValue: '',
|
|
|
|
inputUI: {
|
|
|
|
inputUI: {
|
|
|
|
type: 'text',
|
|
|
|
type: 'directory',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
tooltip: 'Specify ouput directory',
|
|
|
|
tooltip: 'Specify ouput directory',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: 'makeWorkingFile',
|
|
|
|
name: 'keepRelativePath',
|
|
|
|
type: 'boolean',
|
|
|
|
type: 'boolean',
|
|
|
|
defaultValue: 'false',
|
|
|
|
defaultValue: 'false',
|
|
|
|
inputUI: {
|
|
|
|
inputUI: {
|
|
|
|
@ -71,6 +75,32 @@ var details = function () { return ({
|
|
|
|
'true',
|
|
|
|
'true',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
tooltip: 'Specify whether to keep the relative path',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: 'copyToWorkDir',
|
|
|
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
|
|
|
defaultValue: 'false',
|
|
|
|
|
|
|
|
inputUI: {
|
|
|
|
|
|
|
|
type: 'text',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
'false',
|
|
|
|
|
|
|
|
'true',
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
tooltip: 'Specify whether to copy to the working directory',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: 'makeWorkingFile',
|
|
|
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
|
|
|
defaultValue: 'false',
|
|
|
|
|
|
|
|
inputUI: {
|
|
|
|
|
|
|
|
type: 'dropdown',
|
|
|
|
|
|
|
|
options: [
|
|
|
|
|
|
|
|
'false',
|
|
|
|
|
|
|
|
'true',
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
},
|
|
|
|
tooltip: 'Make the copied file the working file',
|
|
|
|
tooltip: 'Make the copied file the working file',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
@ -84,23 +114,54 @@ var details = function () { return ({
|
|
|
|
exports.details = details;
|
|
|
|
exports.details = details;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
|
var plugin = function (args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
|
var lib, originalFileName, newContainer, outputPath, workingFile;
|
|
|
|
var lib, _a, copyToWorkDir, keepRelativePath, makeWorkingFile, outputDirectory, originalFileName, newContainer, outputPath, subStem, ouputFilePath, workingFile;
|
|
|
|
return __generator(this, function (_a) {
|
|
|
|
return __generator(this, function (_b) {
|
|
|
|
switch (_a.label) {
|
|
|
|
switch (_b.label) {
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
|
lib = require('../../../../../methods/lib')();
|
|
|
|
lib = require('../../../../../methods/lib')();
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
|
|
|
|
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
|
|
|
args.inputs = lib.loadDefaultValues(args.inputs, details);
|
|
|
|
|
|
|
|
_a = args.inputs, copyToWorkDir = _a.copyToWorkDir, keepRelativePath = _a.keepRelativePath, makeWorkingFile = _a.makeWorkingFile;
|
|
|
|
|
|
|
|
outputDirectory = String(args.inputs.outputDirectory);
|
|
|
|
originalFileName = (0, fileUtils_1.getFileName)(args.originalLibraryFile._id);
|
|
|
|
originalFileName = (0, fileUtils_1.getFileName)(args.originalLibraryFile._id);
|
|
|
|
newContainer = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
|
|
|
|
newContainer = (0, fileUtils_1.getContainer)(args.inputFileObj._id);
|
|
|
|
outputPath = "".concat(args.inputs.outputDirectory, "/").concat(originalFileName, ".").concat(newContainer);
|
|
|
|
outputPath = '';
|
|
|
|
return [4 /*yield*/, fs_1.promises.copyFile(args.inputFileObj._id, outputPath)];
|
|
|
|
if (copyToWorkDir) {
|
|
|
|
case 1:
|
|
|
|
outputPath = args.workDir;
|
|
|
|
_a.sent();
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (keepRelativePath) {
|
|
|
|
|
|
|
|
subStem = (0, fileUtils_1.getSubStem)({
|
|
|
|
|
|
|
|
inputPathStem: args.librarySettings.folder,
|
|
|
|
|
|
|
|
inputPath: args.originalLibraryFile._id,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
outputPath = (0, normJoinPath_1.default)({
|
|
|
|
|
|
|
|
upath: args.deps.upath,
|
|
|
|
|
|
|
|
paths: [
|
|
|
|
|
|
|
|
outputDirectory,
|
|
|
|
|
|
|
|
subStem,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
outputPath = outputDirectory;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ouputFilePath = (0, normJoinPath_1.default)({
|
|
|
|
|
|
|
|
upath: args.deps.upath,
|
|
|
|
|
|
|
|
paths: [
|
|
|
|
|
|
|
|
outputPath,
|
|
|
|
|
|
|
|
"".concat(originalFileName, ".").concat(newContainer),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
});
|
|
|
|
workingFile = args.inputFileObj._id;
|
|
|
|
workingFile = args.inputFileObj._id;
|
|
|
|
if (args.inputs.makeWorkingFile) {
|
|
|
|
if (makeWorkingFile || copyToWorkDir) {
|
|
|
|
workingFile = outputPath;
|
|
|
|
workingFile = ouputFilePath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
args.jobLog("Input path: ".concat(args.inputFileObj._id));
|
|
|
|
|
|
|
|
args.jobLog("Output path: ".concat(outputPath));
|
|
|
|
|
|
|
|
args.deps.fsextra.ensureDirSync(outputPath);
|
|
|
|
|
|
|
|
return [4 /*yield*/, fs_1.promises.copyFile(args.inputFileObj._id, ouputFilePath)];
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
|
|
_b.sent();
|
|
|
|
return [2 /*return*/, {
|
|
|
|
return [2 /*return*/, {
|
|
|
|
outputFileObj: {
|
|
|
|
outputFileObj: {
|
|
|
|
_id: workingFile,
|
|
|
|
_id: workingFile,
|
|
|
|
|