108 lines
4.0 KiB
JavaScript
108 lines
4.0 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || (function () {
|
|
var ownKeys = function(o) {
|
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
var ar = [];
|
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
return ar;
|
|
};
|
|
return ownKeys(o);
|
|
};
|
|
return function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
})();
|
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.parse = exports.parseSource = exports.testMultiplePaths = exports.clone = void 0;
|
|
const path = __importStar(require("path"));
|
|
const exists_1 = require("@plastichub/fs/exists");
|
|
const osr_commons_1 = require("@plastichub/osr-commons");
|
|
__exportStar(require("./lib"), exports);
|
|
const clone = (obj) => {
|
|
if (null == obj || "object" != typeof obj)
|
|
return obj;
|
|
var copy = obj.constructor();
|
|
for (var attr in obj) {
|
|
if (obj.hasOwnProperty(attr))
|
|
copy[attr] = obj[attr];
|
|
}
|
|
return copy;
|
|
};
|
|
exports.clone = clone;
|
|
const testMultiplePaths = (str) => {
|
|
if (!str)
|
|
return false;
|
|
const paths = str.split(' ');
|
|
return paths.every(p => (0, exists_1.sync)(p));
|
|
};
|
|
exports.testMultiplePaths = testMultiplePaths;
|
|
const parseSource = (src) => {
|
|
if (!src)
|
|
return null;
|
|
if (!src.includes(' '))
|
|
return null;
|
|
};
|
|
exports.parseSource = parseSource;
|
|
const parse = (options, argv) => {
|
|
let srcInfo = null;
|
|
if (options.source) {
|
|
srcInfo = (0, osr_commons_1.pathInfoEx)(options.source);
|
|
//glob patterns
|
|
if (srcInfo && srcInfo.FILES && srcInfo.FILES.length) {
|
|
options.srcInfo = srcInfo;
|
|
for (const key in srcInfo) {
|
|
if (Object.prototype.hasOwnProperty.call(srcInfo, key)) {
|
|
options.variables['SRC_' + key] = srcInfo[key];
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
options.source = path.resolve((0, osr_commons_1.substitute)(options.alt, options.source, options.variables));
|
|
}
|
|
}
|
|
let filesInfo = null;
|
|
if (options.files) {
|
|
filesInfo = (0, osr_commons_1.pathInfoEx)(options.files);
|
|
//glob patterns
|
|
if (filesInfo && filesInfo.FILES && filesInfo.FILES.length) {
|
|
options.filesInfo = filesInfo;
|
|
for (const key in filesInfo) {
|
|
if (Object.prototype.hasOwnProperty.call(filesInfo, key)) {
|
|
options.variables['FILE_' + key] = filesInfo[key];
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
options.files = path.resolve((0, osr_commons_1.substitute)(options.alt, options.files, options.variables));
|
|
}
|
|
}
|
|
if (options.dst) {
|
|
options.dst = path.resolve((0, osr_commons_1.resolve)(options.dst, options.alt, options.variables));
|
|
}
|
|
return options;
|
|
};
|
|
exports.parse = parse;
|
|
//# sourceMappingURL=options.js.map
|