tnp-core 18.0.43 → 18.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/shared/shared_folder_info.txt +1 -1
- package/browser/esm2022/lib/helpers.mjs +23 -28
- package/browser/esm2022/lib/utils.mjs +498 -1
- package/browser/fesm2022/tnp-core.mjs +638 -134
- package/browser/fesm2022/tnp-core.mjs.map +1 -1
- package/browser/lib/helpers.d.ts +5 -3
- package/browser/lib/utils.d.ts +117 -0
- package/cli.backend.js +2 -2
- package/client/esm2022/lib/helpers.mjs +23 -28
- package/client/esm2022/lib/utils.mjs +498 -1
- package/client/fesm2022/tnp-core.mjs +638 -134
- package/client/fesm2022/tnp-core.mjs.map +1 -1
- package/client/lib/helpers.d.ts +5 -3
- package/client/lib/utils.d.ts +117 -0
- package/lib/helpers.d.ts +15 -4
- package/lib/helpers.js +156 -172
- package/lib/helpers.js.map +1 -1
- package/lib/node-chalk-mock.js +2 -2
- package/lib/node-path-mock.js +2 -2
- package/lib/utils.d.ts +120 -0
- package/lib/utils.js +580 -1
- package/lib/utils.js.map +1 -1
- package/package.json +2 -2
- package/tmp-environment.json +30 -29
- package/websql/esm2022/lib/helpers.mjs +23 -28
- package/websql/esm2022/lib/utils.mjs +498 -1
- package/websql/fesm2022/tnp-core.mjs +726 -222
- package/websql/fesm2022/tnp-core.mjs.map +1 -1
- package/websql/lib/helpers.d.ts +5 -3
- package/websql/lib/utils.d.ts +117 -0
package/lib/helpers.js
CHANGED
@@ -3,20 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HelpersCore = void 0;
|
4
4
|
var tslib_1 = require("tslib");
|
5
5
|
//#region import
|
6
|
-
var core_imports_1 = require("./core-imports");
|
7
|
-
var index_1 = require("./index");
|
8
|
-
var helpers_messages_1 = require("./helpers-messages");
|
9
|
-
var core_models_1 = require("./core-models");
|
10
|
-
/* */
|
11
|
-
/* */
|
12
6
|
//#region @backend
|
7
|
+
var core_imports_1 = require("./core-imports");
|
13
8
|
var json5Write = require("json10-writer");
|
14
9
|
var buffer_1 = require("buffer");
|
15
10
|
var electron_1 = require("electron");
|
11
|
+
//#endregion
|
12
|
+
/* */
|
13
|
+
/* */
|
14
|
+
var core_imports_2 = require("./core-imports");
|
15
|
+
var utils_1 = require("./utils");
|
16
|
+
var index_1 = require("./index");
|
17
|
+
var helpers_messages_1 = require("./helpers-messages");
|
18
|
+
var core_models_1 = require("./core-models");
|
16
19
|
var encoding = 'utf8';
|
17
20
|
//#region @backend
|
18
21
|
var forceTrace = !global.hideLog;
|
19
|
-
var prompts = require('prompts');
|
20
22
|
//#endregion
|
21
23
|
var WEBSQL_PROC_MOCK_PROCESSES_PID = {};
|
22
24
|
var WEBSQL_PROC_MOCK_PROCESSES_PPID = {};
|
@@ -56,13 +58,22 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
56
58
|
});
|
57
59
|
Object.defineProperty(HelpersCore.prototype, "isRunningIn", {
|
58
60
|
//#region @backend
|
61
|
+
/**
|
62
|
+
* @deprecated use UtilsOs
|
63
|
+
*/
|
59
64
|
get: function () {
|
60
65
|
return {
|
66
|
+
/**
|
67
|
+
* @deprecated use UtilsOs.isRunningInMochaTest()
|
68
|
+
*/
|
61
69
|
mochaTest: function () {
|
62
|
-
return
|
70
|
+
return index_1.UtilsOs.isRunningInMochaTest();
|
63
71
|
},
|
72
|
+
/**
|
73
|
+
* @deprecated use UtilsOs.isRunningInCliMode()
|
74
|
+
*/
|
64
75
|
cliMode: function () {
|
65
|
-
return
|
76
|
+
return index_1.UtilsOs.isRunningInCliMode();
|
66
77
|
},
|
67
78
|
};
|
68
79
|
},
|
@@ -99,15 +110,11 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
99
110
|
};
|
100
111
|
//#endregion
|
101
112
|
//#region clear console
|
113
|
+
/**
|
114
|
+
* @deprecated use UtilsTerminal.clearConsole
|
115
|
+
*/
|
102
116
|
HelpersCore.prototype.clearConsole = function () {
|
103
|
-
|
104
|
-
console.log('\x1Bc');
|
105
|
-
// process.stdout.write('\033c\033[3J');
|
106
|
-
// try {
|
107
|
-
// run('clear').sync()
|
108
|
-
// } catch (error) {
|
109
|
-
// console.log('clear console not succedd')
|
110
|
-
// }
|
117
|
+
return utils_1.UtilsTerminal.clearConsole();
|
111
118
|
};
|
112
119
|
Object.defineProperty(HelpersCore.prototype, "ipcRenderer", {
|
113
120
|
//#endregion
|
@@ -189,9 +196,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
189
196
|
//#endregion
|
190
197
|
//#region methods / media from type
|
191
198
|
HelpersCore.prototype.mediaTypeFromSrc = function (src) {
|
192
|
-
var ext =
|
199
|
+
var ext = core_imports_2.path.extname(src);
|
193
200
|
var media = core_models_1.CoreModels.mimeTypes[ext];
|
194
|
-
return
|
201
|
+
return core_imports_2._.first(media === null || media === void 0 ? void 0 : media.split('/'));
|
195
202
|
};
|
196
203
|
//#endregion
|
197
204
|
//#region methods / sleep
|
@@ -206,7 +213,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
206
213
|
HelpersCore.prototype.removeIfExists = function (absoluteFileOrFolderPath) {
|
207
214
|
//#region @backendFunc
|
208
215
|
if (Array.isArray(absoluteFileOrFolderPath)) {
|
209
|
-
absoluteFileOrFolderPath = (0,
|
216
|
+
absoluteFileOrFolderPath = (0, core_imports_2.crossPlatformPath)(absoluteFileOrFolderPath);
|
210
217
|
}
|
211
218
|
if (process.platform === 'win32') {
|
212
219
|
core_imports_1.rimraf.sync(absoluteFileOrFolderPath);
|
@@ -232,14 +239,14 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
232
239
|
* path.relative that return cross platform path
|
233
240
|
*/
|
234
241
|
HelpersCore.prototype.relative = function (cwd, to) {
|
235
|
-
return (0,
|
242
|
+
return (0, core_imports_2.crossPlatformPath)(core_imports_2.path.relative(cwd, to));
|
236
243
|
};
|
237
244
|
//#endregion
|
238
245
|
//#region methods / remove file if exists
|
239
246
|
HelpersCore.prototype.removeFileIfExists = function (absoluteFilePath) {
|
240
247
|
//#region @backendFunc
|
241
248
|
if (Array.isArray(absoluteFilePath)) {
|
242
|
-
absoluteFilePath = (0,
|
249
|
+
absoluteFilePath = (0, core_imports_2.crossPlatformPath)(absoluteFilePath);
|
243
250
|
}
|
244
251
|
if (process.platform === 'win32') {
|
245
252
|
core_imports_1.rimraf.sync(absoluteFilePath);
|
@@ -256,7 +263,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
256
263
|
HelpersCore.prototype.removeFolderIfExists = function (absoluteFolderPath) {
|
257
264
|
//#region @backendFunc
|
258
265
|
if (Array.isArray(absoluteFolderPath)) {
|
259
|
-
absoluteFolderPath = (0,
|
266
|
+
absoluteFolderPath = (0, core_imports_2.crossPlatformPath)(absoluteFolderPath);
|
260
267
|
}
|
261
268
|
index_1.Helpers.log("[helpers] Remove folder: ".concat(absoluteFolderPath));
|
262
269
|
if (process.platform === 'win32') {
|
@@ -309,7 +316,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
309
316
|
//#region @backendFunc
|
310
317
|
if (!core_imports_1.fse.existsSync(dirpath)) {
|
311
318
|
if (!omitWarningNotExisted) {
|
312
|
-
index_1.Helpers.warn("[taon-helper][tryRemoveDir] Folder ".concat(
|
319
|
+
index_1.Helpers.warn("[taon-helper][tryRemoveDir] Folder ".concat(core_imports_2.path.basename(dirpath), " doesn't exist."));
|
313
320
|
}
|
314
321
|
return;
|
315
322
|
}
|
@@ -337,7 +344,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
337
344
|
if (exactFolder === void 0) { exactFolder = false; }
|
338
345
|
//#region @backendFunc
|
339
346
|
if (Array.isArray(fileOrFolderPathOrPatter)) {
|
340
|
-
fileOrFolderPathOrPatter = (0,
|
347
|
+
fileOrFolderPathOrPatter = (0, core_imports_2.crossPlatformPath)(fileOrFolderPathOrPatter);
|
341
348
|
}
|
342
349
|
index_1.Helpers.log("[taon-core][remove]: ".concat(fileOrFolderPathOrPatter), 1);
|
343
350
|
if (exactFolder) {
|
@@ -465,7 +472,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
465
472
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
466
473
|
var promisOrValue, functionFn, context, arrayOfParams;
|
467
474
|
return tslib_1.__generator(this, function (_a) {
|
468
|
-
if (
|
475
|
+
if (core_imports_2._.isUndefined(fnOrOptions)) {
|
469
476
|
return [2 /*return*/, void 0];
|
470
477
|
}
|
471
478
|
functionFn = fnOrOptions.functionFn, context = fnOrOptions.context, arrayOfParams = fnOrOptions.arrayOfParams;
|
@@ -489,27 +496,27 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
489
496
|
//#region @backend
|
490
497
|
HelpersCore.prototype.createSymLink = function (existedFileOrFolder, destinationPath, options) {
|
491
498
|
//#region fix parameters
|
492
|
-
existedFileOrFolder = (0,
|
493
|
-
destinationPath = (0,
|
499
|
+
existedFileOrFolder = (0, core_imports_2.crossPlatformPath)(existedFileOrFolder);
|
500
|
+
destinationPath = (0, core_imports_2.crossPlatformPath)(destinationPath);
|
494
501
|
// console.trace(`Creating link:
|
495
502
|
// from: ${existedFileOrFolder},
|
496
503
|
// to: ${destinationPath},
|
497
504
|
// `)
|
498
505
|
index_1.Helpers.log("[tnp-code][create link] exited -> dest\n ".concat(existedFileOrFolder, " ").concat(destinationPath), 1);
|
499
506
|
options = options ? options : {};
|
500
|
-
if (
|
507
|
+
if (core_imports_2._.isUndefined(options.continueWhenExistedFolderDoesntExists)) {
|
501
508
|
options.continueWhenExistedFolderDoesntExists = false;
|
502
509
|
}
|
503
|
-
if (
|
510
|
+
if (core_imports_2._.isUndefined(options.dontRenameWhenSlashAtEnd)) {
|
504
511
|
options.dontRenameWhenSlashAtEnd = false;
|
505
512
|
}
|
506
|
-
if (
|
513
|
+
if (core_imports_2._.isUndefined(options.windowsHardLink)) {
|
507
514
|
options.windowsHardLink = false;
|
508
515
|
}
|
509
|
-
if (
|
516
|
+
if (core_imports_2._.isUndefined(options.speedUpProcess)) {
|
510
517
|
options.speedUpProcess = false;
|
511
518
|
}
|
512
|
-
if (
|
519
|
+
if (core_imports_2._.isUndefined(options.allowNotAbsolutePathes)) {
|
513
520
|
options.allowNotAbsolutePathes = false;
|
514
521
|
}
|
515
522
|
//#endregion
|
@@ -533,27 +540,27 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
533
540
|
*/
|
534
541
|
if (options.allowNotAbsolutePathes) {
|
535
542
|
if (linkDest === '.' || linkDest === './') {
|
536
|
-
linkDest = (0,
|
543
|
+
linkDest = (0, core_imports_2.crossPlatformPath)(process.cwd());
|
537
544
|
}
|
538
|
-
if (!
|
539
|
-
linkDest = (0,
|
545
|
+
if (!core_imports_2.path.isAbsolute(linkDest)) {
|
546
|
+
linkDest = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join((0, core_imports_2.crossPlatformPath)(process.cwd()), linkDest));
|
540
547
|
}
|
541
|
-
if (!
|
542
|
-
targetExisted = (0,
|
548
|
+
if (!core_imports_2.path.isAbsolute(targetExisted)) {
|
549
|
+
targetExisted = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join((0, core_imports_2.crossPlatformPath)(process.cwd()), targetExisted));
|
543
550
|
}
|
544
551
|
}
|
545
552
|
else {
|
546
|
-
if (!
|
553
|
+
if (!core_imports_2.path.isAbsolute(linkDest)) {
|
547
554
|
index_1.Helpers.error("[createsymlink] path is not absolute:\n targetExisted: ".concat(targetExisted, "\n linkDest: ").concat(linkDest, "\n "));
|
548
555
|
}
|
549
|
-
if (!
|
556
|
+
if (!core_imports_2.path.isAbsolute(targetExisted)) {
|
550
557
|
index_1.Helpers.error("[createsymlink] path is not absolute:\n targetExisted: ".concat(targetExisted, "\n linkDest: ").concat(linkDest, "\n "));
|
551
558
|
}
|
552
559
|
}
|
553
560
|
if (linkDest.endsWith('/')) {
|
554
|
-
linkDest = (0,
|
561
|
+
linkDest = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join(linkDest, core_imports_2.path.basename(targetExisted)));
|
555
562
|
}
|
556
|
-
var parentFolderLinkDest =
|
563
|
+
var parentFolderLinkDest = core_imports_2.path.dirname(linkDest);
|
557
564
|
if (index_1.Helpers.isSymlinkFileExitedOrUnexisted(parentFolderLinkDest)) {
|
558
565
|
core_imports_1.fse.unlinkSync(parentFolderLinkDest);
|
559
566
|
}
|
@@ -570,7 +577,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
570
577
|
// console.log(`resolved target from ${targetExisted} = ${resolvedTarget}, isFile: ${targetIsFile}`)
|
571
578
|
if (index_1.Helpers.isSymlinkFileExitedOrUnexisted(targetExisted)) {
|
572
579
|
// Helpers.info(`FIXING TARGET FOR WINDOWS`)
|
573
|
-
targetExisted = (0,
|
580
|
+
targetExisted = (0, core_imports_2.crossPlatformPath)(core_imports_1.fse.realpathSync(targetExisted));
|
574
581
|
// TODO QUICK_FIX on windows you can't create link to link
|
575
582
|
}
|
576
583
|
// targetExisted = path.win32.normalize(targetExisted).replace(/\\$/, '');
|
@@ -640,14 +647,14 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
640
647
|
return index_1.Helpers.mkdirp(folderPath);
|
641
648
|
};
|
642
649
|
HelpersCore.prototype.mkdirp = function (folderPath) {
|
643
|
-
if (
|
644
|
-
folderPath = (0,
|
650
|
+
if (core_imports_2._.isArray(folderPath)) {
|
651
|
+
folderPath = (0, core_imports_2.crossPlatformPath)(folderPath);
|
645
652
|
}
|
646
|
-
if (!
|
653
|
+
if (!core_imports_2.path.isAbsolute(folderPath)) {
|
647
654
|
index_1.Helpers.warn("[taon-core][mkdirp] Path is not absolute, abort ".concat(folderPath), true);
|
648
655
|
return;
|
649
656
|
}
|
650
|
-
if (
|
657
|
+
if (core_imports_2._.isString(folderPath) &&
|
651
658
|
folderPath.startsWith('/tmp ') &&
|
652
659
|
core_imports_1.os.platform() === 'darwin') {
|
653
660
|
index_1.Helpers.warn("[taon-core][mkdirp] On mac osx /tmp is changed to /private/tmp", false);
|
@@ -680,14 +687,14 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
680
687
|
HelpersCore.prototype.isSymlinkThatMatchesUrl = function (possibleSymlink, destUrl, absoluteFileMatch) {
|
681
688
|
if (absoluteFileMatch === void 0) { absoluteFileMatch = false; }
|
682
689
|
//#region @backendFunc
|
683
|
-
destUrl = (0,
|
690
|
+
destUrl = (0, core_imports_2.crossPlatformPath)(destUrl);
|
684
691
|
if (index_1.Helpers.exists(possibleSymlink)) {
|
685
692
|
if (index_1.Helpers.isExistedSymlink(possibleSymlink)) {
|
686
693
|
var fileLink = core_imports_1.fse.readlinkSync(possibleSymlink);
|
687
694
|
if (absoluteFileMatch) {
|
688
695
|
fileLink = core_imports_1.fse.realpathSync(fileLink);
|
689
696
|
}
|
690
|
-
fileLink = (0,
|
697
|
+
fileLink = (0, core_imports_2.crossPlatformPath)(fileLink);
|
691
698
|
return fileLink === destUrl;
|
692
699
|
}
|
693
700
|
if (index_1.Helpers.isFolder(possibleSymlink)) {
|
@@ -703,7 +710,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
703
710
|
if (absoluteFileMatch) {
|
704
711
|
fileLink = core_imports_1.fse.realpathSync(fileLink);
|
705
712
|
}
|
706
|
-
fileLink = (0,
|
713
|
+
fileLink = (0, core_imports_2.crossPlatformPath)(fileLink);
|
707
714
|
return fileLink === destUrl;
|
708
715
|
}
|
709
716
|
return false;
|
@@ -717,8 +724,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
717
724
|
//#region methods / is symlink file existed or unexisted
|
718
725
|
HelpersCore.prototype.isSymlinkFileExitedOrUnexisted = function (filePath) {
|
719
726
|
//#region @backendFunc
|
720
|
-
if (
|
721
|
-
filePath = (0,
|
727
|
+
if (core_imports_2._.isArray(filePath)) {
|
728
|
+
filePath = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join.apply(core_imports_2.path, tslib_1.__spreadArray([], tslib_1.__read(filePath), false)));
|
722
729
|
}
|
723
730
|
try {
|
724
731
|
var linkToUnexitedLink = core_imports_1.fse.lstatSync(filePath).isSymbolicLink();
|
@@ -736,12 +743,12 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
736
743
|
*/
|
737
744
|
HelpersCore.prototype.isUnexistedLink = function (filePath) {
|
738
745
|
//#region @backendFunc
|
739
|
-
if (
|
740
|
-
filePath = (0,
|
746
|
+
if (core_imports_2._.isArray(filePath)) {
|
747
|
+
filePath = (0, core_imports_2.crossPlatformPath)(filePath);
|
741
748
|
}
|
742
749
|
filePath = index_1.Helpers.removeSlashAtEnd(filePath);
|
743
750
|
if (process.platform === 'win32') {
|
744
|
-
filePath =
|
751
|
+
filePath = core_imports_2.path.win32.normalize(filePath);
|
745
752
|
}
|
746
753
|
try {
|
747
754
|
var linkToUnexitedLink = core_imports_1.fse
|
@@ -762,12 +769,12 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
762
769
|
*/
|
763
770
|
HelpersCore.prototype.isExistedSymlink = function (filePath) {
|
764
771
|
//#region @backendFunc
|
765
|
-
if (
|
766
|
-
filePath = (0,
|
772
|
+
if (core_imports_2._.isArray(filePath)) {
|
773
|
+
filePath = (0, core_imports_2.crossPlatformPath)(filePath);
|
767
774
|
}
|
768
775
|
filePath = index_1.Helpers.removeSlashAtEnd(filePath);
|
769
776
|
if (process.platform === 'win32') {
|
770
|
-
filePath =
|
777
|
+
filePath = core_imports_2.path.win32.normalize(filePath);
|
771
778
|
}
|
772
779
|
try {
|
773
780
|
var linkToUnexitedLink = core_imports_1.fse
|
@@ -787,7 +794,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
787
794
|
HelpersCore.prototype.pathContainLink = function (p) {
|
788
795
|
var previous;
|
789
796
|
while (true) {
|
790
|
-
p = (0,
|
797
|
+
p = (0, core_imports_2.crossPlatformPath)(core_imports_2.path.dirname(p));
|
791
798
|
// @ts-ignore
|
792
799
|
if (p === previous) {
|
793
800
|
return false;
|
@@ -806,14 +813,14 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
806
813
|
//#region methods / exists
|
807
814
|
HelpersCore.prototype.exists = function (folderOrFilePath) {
|
808
815
|
//#region @backendFunc
|
809
|
-
if (
|
810
|
-
folderOrFilePath = (0,
|
816
|
+
if (core_imports_2._.isArray(folderOrFilePath)) {
|
817
|
+
folderOrFilePath = (0, core_imports_2.crossPlatformPath)(folderOrFilePath);
|
811
818
|
}
|
812
819
|
if (!folderOrFilePath) {
|
813
820
|
index_1.Helpers.warn("[taon-core][exists] Path is not a string, abort.. \"".concat(folderOrFilePath, "\""), true);
|
814
821
|
return false;
|
815
822
|
}
|
816
|
-
if (!
|
823
|
+
if (!core_imports_2.path.isAbsolute(folderOrFilePath)) {
|
817
824
|
index_1.Helpers.warn("[taon-core]\n File path is not absolute:\n ".concat(folderOrFilePath, "\n\n "), true);
|
818
825
|
return false;
|
819
826
|
}
|
@@ -913,7 +920,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
913
920
|
HelpersCore.prototype.commnadOutputAsStringAsync = function (command_1) {
|
914
921
|
return tslib_1.__awaiter(this, arguments, void 0, function (command, cwd, options) {
|
915
922
|
var opt, output, splited, e_1;
|
916
|
-
if (cwd === void 0) { cwd = (0,
|
923
|
+
if (cwd === void 0) { cwd = (0, core_imports_2.crossPlatformPath)(process.cwd()); }
|
917
924
|
return tslib_1.__generator(this, function (_a) {
|
918
925
|
switch (_a.label) {
|
919
926
|
case 0:
|
@@ -959,7 +966,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
959
966
|
//#region @backend
|
960
967
|
HelpersCore.prototype.commnadOutputAsString = function (command, cwd, options) {
|
961
968
|
var _a;
|
962
|
-
if (cwd === void 0) { cwd = (0,
|
969
|
+
if (cwd === void 0) { cwd = (0, core_imports_2.crossPlatformPath)(process.cwd()); }
|
963
970
|
command = index_1.Helpers._fixCommand(command);
|
964
971
|
var opt = (options || {});
|
965
972
|
var output = '';
|
@@ -1002,7 +1009,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1002
1009
|
switch (_a.label) {
|
1003
1010
|
case 0:
|
1004
1011
|
showOutoput = !options || !options.silent;
|
1005
|
-
if (!
|
1012
|
+
if (!core_imports_2._.isArray(portOrPortsToKill)) {
|
1006
1013
|
portOrPortsToKill = [portOrPortsToKill];
|
1007
1014
|
}
|
1008
1015
|
index = 0;
|
@@ -1013,7 +1020,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1013
1020
|
index_1.Helpers.info("[taon-helpers] Killing process on port: ".concat(port));
|
1014
1021
|
org = port;
|
1015
1022
|
port = Number(port);
|
1016
|
-
if (!
|
1023
|
+
if (!core_imports_2._.isNumber(port)) {
|
1017
1024
|
showOutoput &&
|
1018
1025
|
index_1.Helpers.warn("[taon-helpers] Can't kill on port: \"".concat(org, "\""));
|
1019
1026
|
return [2 /*return*/];
|
@@ -1099,8 +1106,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1099
1106
|
if (options.biggerBuffer === void 0)
|
1100
1107
|
options.biggerBuffer = false;
|
1101
1108
|
if (options.cwd === void 0)
|
1102
|
-
options.cwd = (0,
|
1103
|
-
if (!
|
1109
|
+
options.cwd = (0, core_imports_2.crossPlatformPath)(process.cwd());
|
1110
|
+
if (!core_imports_2._.isString(command)) {
|
1104
1111
|
index_1.Helpers.error("[taon-helpers] command is not a string");
|
1105
1112
|
}
|
1106
1113
|
//#endregion
|
@@ -1112,11 +1119,11 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1112
1119
|
// TODO buffer
|
1113
1120
|
//#region @backendFunc
|
1114
1121
|
// @ts-ignore
|
1115
|
-
if (
|
1122
|
+
if (core_imports_2._.isArray(options.extractFromLine)) {
|
1116
1123
|
index_1.Helpers.error("[tnp-helper] extractFromLine only for:\n - asyncAsPromise\n - async\n - unitlOutputContains\n\n ", false, true);
|
1117
1124
|
}
|
1118
1125
|
// @ts-ignore
|
1119
|
-
if (
|
1126
|
+
if (core_imports_2._.isNumber(options.tryAgainWhenFailAfter) &&
|
1120
1127
|
options.tryAgainWhenFailAfter > 0) {
|
1121
1128
|
// TODO try again when fail
|
1122
1129
|
// try {
|
@@ -1273,13 +1280,13 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1273
1280
|
var stdoutMsg = optionsOutput.stdoutMsg, stderMsg = optionsOutput.stderMsg, timeout = optionsOutput.timeout, stdoutOutputContainsCallback = optionsOutput.stdoutOutputContainsCallback;
|
1274
1281
|
var isResolved = false;
|
1275
1282
|
return new Promise(function (resolve, reject) {
|
1276
|
-
if (
|
1283
|
+
if (core_imports_2._.isString(stdoutMsg)) {
|
1277
1284
|
stdoutMsg = [stdoutMsg];
|
1278
1285
|
}
|
1279
|
-
if (
|
1286
|
+
if (core_imports_2._.isString(stderMsg)) {
|
1280
1287
|
stderMsg = [stderMsg];
|
1281
1288
|
}
|
1282
|
-
if (!
|
1289
|
+
if (!core_imports_2._.isArray(stdoutMsg)) {
|
1283
1290
|
reject("[unitlOutputContains] Message not a array");
|
1284
1291
|
}
|
1285
1292
|
var proc = index_1.Helpers.runAsyncIn(command, options);
|
@@ -1290,7 +1297,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1290
1297
|
// @ts-ignore
|
1291
1298
|
proc.stderr.on('data', function (message) {
|
1292
1299
|
var data = message.toString().trim();
|
1293
|
-
if (!isResolved &&
|
1300
|
+
if (!isResolved && core_imports_2._.isArray(stderMsg)) {
|
1294
1301
|
for (var index = 0; index < stderMsg.length; index++) {
|
1295
1302
|
var rejectm = stderMsg[index];
|
1296
1303
|
if (data.search(rejectm) !== -1) {
|
@@ -1336,7 +1343,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1336
1343
|
}
|
1337
1344
|
}
|
1338
1345
|
}
|
1339
|
-
if (!isResolved &&
|
1346
|
+
if (!isResolved && core_imports_2._.isArray(stderMsg)) {
|
1340
1347
|
for (var index = 0; index < stderMsg.length; index++) {
|
1341
1348
|
var rejectm = stderMsg[index];
|
1342
1349
|
if (data.search(rejectm) !== -1) {
|
@@ -1365,20 +1372,20 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1365
1372
|
//#region @backendFunc
|
1366
1373
|
var isResolved = false;
|
1367
1374
|
return new Promise(function (resolve, reject) {
|
1368
|
-
if (
|
1375
|
+
if (core_imports_2._.isString(stdoutMsg)) {
|
1369
1376
|
stdoutMsg = [stdoutMsg];
|
1370
1377
|
}
|
1371
|
-
if (
|
1378
|
+
if (core_imports_2._.isString(stderMsg)) {
|
1372
1379
|
stderMsg = [stderMsg];
|
1373
1380
|
}
|
1374
|
-
if (!
|
1381
|
+
if (!core_imports_2._.isArray(stdoutMsg)) {
|
1375
1382
|
reject("[unitlOutputContains] Message not a array");
|
1376
1383
|
}
|
1377
1384
|
var proc = index_1.Helpers.runAsyncIn(command, options);
|
1378
1385
|
// @ts-ignore
|
1379
1386
|
proc.stderr.on('data', function (message) {
|
1380
1387
|
var data = message.toString().trim();
|
1381
|
-
if (!isResolved &&
|
1388
|
+
if (!isResolved && core_imports_2._.isArray(stderMsg)) {
|
1382
1389
|
for (var index = 0; index < stderMsg.length; index++) {
|
1383
1390
|
var rejectm = stderMsg[index];
|
1384
1391
|
if (data.search(rejectm) !== -1) {
|
@@ -1421,7 +1428,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1421
1428
|
}
|
1422
1429
|
}
|
1423
1430
|
}
|
1424
|
-
if (!isResolved &&
|
1431
|
+
if (!isResolved && core_imports_2._.isArray(stderMsg)) {
|
1425
1432
|
for (var index = 0; index < stderMsg.length; index++) {
|
1426
1433
|
var rejectm = stderMsg[index];
|
1427
1434
|
if (data.search(rejectm) !== -1) {
|
@@ -1443,50 +1450,27 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1443
1450
|
};
|
1444
1451
|
//#endregion
|
1445
1452
|
//#region methods / question yest no
|
1453
|
+
/**
|
1454
|
+
* @deprecated use UtilsTerminal.confirm
|
1455
|
+
*/
|
1446
1456
|
HelpersCore.prototype.questionYesNo = function (message_1, callbackTrue_1, callbackFalse_1) {
|
1447
|
-
return tslib_1.__awaiter(this, arguments, void 0, function (message, callbackTrue, callbackFalse, defaultValue
|
1448
|
-
/**
|
1449
|
-
* in non interactive mode
|
1450
|
-
*/
|
1451
|
-
mustAnswerQuestion) {
|
1452
|
-
var response;
|
1457
|
+
return tslib_1.__awaiter(this, arguments, void 0, function (message, callbackTrue, callbackFalse, defaultValue) {
|
1453
1458
|
if (defaultValue === void 0) { defaultValue = true; }
|
1454
|
-
if (mustAnswerQuestion === void 0) { mustAnswerQuestion = false; }
|
1455
1459
|
return tslib_1.__generator(this, function (_a) {
|
1456
1460
|
switch (_a.label) {
|
1457
|
-
case 0:
|
1458
|
-
response = {
|
1459
|
-
value: defaultValue,
|
1460
|
-
};
|
1461
|
-
if (!(global.tnpNonInteractive && !mustAnswerQuestion)) return [3 /*break*/, 1];
|
1462
|
-
index_1.Helpers.info("".concat(message, " - AUTORESPONSE: ").concat(defaultValue ? 'YES' : 'NO'));
|
1463
|
-
return [3 /*break*/, 3];
|
1464
|
-
case 1: return [4 /*yield*/, prompts({
|
1465
|
-
type: 'toggle',
|
1466
|
-
name: 'value',
|
1461
|
+
case 0: return [4 /*yield*/, utils_1.UtilsTerminal.confirm({
|
1467
1462
|
message: message,
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
})
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
case 4:
|
1480
|
-
_a.sent();
|
1481
|
-
_a.label = 5;
|
1482
|
-
case 5: return [3 /*break*/, 8];
|
1483
|
-
case 6:
|
1484
|
-
if (!callbackFalse) return [3 /*break*/, 8];
|
1485
|
-
return [4 /*yield*/, index_1.Helpers.runSyncOrAsync({ functionFn: callbackFalse })];
|
1486
|
-
case 7:
|
1487
|
-
_a.sent();
|
1488
|
-
_a.label = 8;
|
1489
|
-
case 8: return [2 /*return*/, response.value];
|
1463
|
+
callbackTrue: callbackTrue,
|
1464
|
+
callbackFalse: callbackFalse,
|
1465
|
+
defaultValue: defaultValue,
|
1466
|
+
})
|
1467
|
+
//#endregion
|
1468
|
+
];
|
1469
|
+
case 1:
|
1470
|
+
//#region @backendFunc
|
1471
|
+
return [2 /*return*/, _a.sent()
|
1472
|
+
//#endregion
|
1473
|
+
];
|
1490
1474
|
}
|
1491
1475
|
});
|
1492
1476
|
});
|
@@ -1503,7 +1487,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1503
1487
|
}
|
1504
1488
|
var resstdio = output
|
1505
1489
|
? [0, 1, 2]
|
1506
|
-
:
|
1490
|
+
: core_imports_2._.isBoolean(silence) && silence
|
1507
1491
|
? 'ignore'
|
1508
1492
|
: undefined;
|
1509
1493
|
// if (pipeToParentProcerss) {
|
@@ -1539,7 +1523,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1539
1523
|
var proc;
|
1540
1524
|
if (detach) {
|
1541
1525
|
//#region detached
|
1542
|
-
var cmd =
|
1526
|
+
var cmd = core_imports_2._.first(command.split(' '));
|
1543
1527
|
var argsForCmd = command.split(' ').slice(1);
|
1544
1528
|
index_1.Helpers.log("cmd: \"".concat(cmd, "\", args: \"").concat(argsForCmd.join(' '), "\""));
|
1545
1529
|
if (process.platform === 'win32') {
|
@@ -1651,10 +1635,10 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1651
1635
|
hideOutput = {};
|
1652
1636
|
}
|
1653
1637
|
isResolved = false;
|
1654
|
-
if (
|
1638
|
+
if (core_imports_2._.isString(resolvePromiseMsg.stdout)) {
|
1655
1639
|
resolvePromiseMsg.stdout = [resolvePromiseMsg.stdout];
|
1656
1640
|
}
|
1657
|
-
if (
|
1641
|
+
if (core_imports_2._.isString(resolvePromiseMsg.stderr)) {
|
1658
1642
|
resolvePromiseMsg.stderr = [resolvePromiseMsg.stderr];
|
1659
1643
|
}
|
1660
1644
|
handlProc = function (proc) {
|
@@ -1671,7 +1655,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1671
1655
|
if (!hideOutput.stdout) {
|
1672
1656
|
process.stdout.write(data);
|
1673
1657
|
}
|
1674
|
-
if (
|
1658
|
+
if (core_imports_2._.isArray(resolvePromiseMsg.stdout)) {
|
1675
1659
|
for (var index = 0; index < resolvePromiseMsg.stdout.length; index++) {
|
1676
1660
|
// console.log(`DATA STDOUT: ${chalk.gray(data)}`);
|
1677
1661
|
var resolveCompilationMessage = resolvePromiseMsg.stdout[index];
|
@@ -1688,7 +1672,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1688
1672
|
}
|
1689
1673
|
}
|
1690
1674
|
// TODO NOT NEEDED
|
1691
|
-
if (
|
1675
|
+
if (core_imports_2._.isArray(resolvePromiseMsg.stderr)) {
|
1692
1676
|
for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) {
|
1693
1677
|
var rejectm = resolvePromiseMsg.stderr[index];
|
1694
1678
|
if (data.search(rejectm) !== -1) {
|
@@ -1717,7 +1701,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1717
1701
|
return [3 /*break*/, 9];
|
1718
1702
|
case 1:
|
1719
1703
|
if (!(code !== 0)) return [3 /*break*/, 8];
|
1720
|
-
if (!
|
1704
|
+
if (!core_imports_2._.isFunction(exitOnErrorCallback)) return [3 /*break*/, 6];
|
1721
1705
|
_a.label = 2;
|
1722
1706
|
case 2:
|
1723
1707
|
_a.trys.push([2, 4, , 5]);
|
@@ -1765,7 +1749,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1765
1749
|
if (!hideOutput.stderr) {
|
1766
1750
|
process.stderr.write(data);
|
1767
1751
|
}
|
1768
|
-
if (
|
1752
|
+
if (core_imports_2._.isArray(resolvePromiseMsg.stderr)) {
|
1769
1753
|
// @ts-ignore
|
1770
1754
|
for (var index = 0; index < resolvePromiseMsg.stderr.length; index++) {
|
1771
1755
|
// @ts-ignore
|
@@ -1848,9 +1832,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1848
1832
|
//#region methods / modify line by line
|
1849
1833
|
//#region @backend
|
1850
1834
|
HelpersCore.prototype.modifyLineByLine = function (data, outputLineReplace, prefix, extractFromLine) {
|
1851
|
-
var checkExtract =
|
1852
|
-
var modifyOutput =
|
1853
|
-
if (modifyOutput &&
|
1835
|
+
var checkExtract = core_imports_2._.isArray(extractFromLine) && extractFromLine.length > 0;
|
1836
|
+
var modifyOutput = core_imports_2._.isFunction(outputLineReplace);
|
1837
|
+
if (modifyOutput && core_imports_2._.isString(data)) {
|
1854
1838
|
data = data
|
1855
1839
|
.split(/\r?\n/)
|
1856
1840
|
.map(function (line) {
|
@@ -1858,7 +1842,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1858
1842
|
})
|
1859
1843
|
.join('\n');
|
1860
1844
|
}
|
1861
|
-
if (prefix &&
|
1845
|
+
if (prefix && core_imports_2._.isString(data)) {
|
1862
1846
|
return data
|
1863
1847
|
.split('\n')
|
1864
1848
|
.map(function (singleLine) {
|
@@ -1868,10 +1852,10 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1868
1852
|
return singleLine;
|
1869
1853
|
}
|
1870
1854
|
if (checkExtract) {
|
1871
|
-
var sFuncs = extractFromLine.filter(function (f) { return
|
1855
|
+
var sFuncs = extractFromLine.filter(function (f) { return core_imports_2._.isString(f); });
|
1872
1856
|
if (sFuncs.filter(function (f) { return singleLine.search(f) !== -1; })
|
1873
1857
|
.length === sFuncs.length) {
|
1874
|
-
var fun = extractFromLine.find(function (f) { return
|
1858
|
+
var fun = extractFromLine.find(function (f) { return core_imports_2._.isFunction(f); });
|
1875
1859
|
if (fun) {
|
1876
1860
|
var s_1 = singleLine;
|
1877
1861
|
sFuncs.forEach(function (f) {
|
@@ -1904,7 +1888,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1904
1888
|
* @deprecated
|
1905
1889
|
*/
|
1906
1890
|
HelpersCore.prototype.values = function (obj) {
|
1907
|
-
if (
|
1891
|
+
if (core_imports_2._.isObject(obj) && !Array.isArray(obj)) {
|
1908
1892
|
var values = [];
|
1909
1893
|
for (var key in obj) {
|
1910
1894
|
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
@@ -1970,8 +1954,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
1970
1954
|
defaultValueWhenNotExists, notTrim) {
|
1971
1955
|
if (defaultValueWhenNotExists === void 0) { defaultValueWhenNotExists = void 0; }
|
1972
1956
|
if (notTrim === void 0) { notTrim = false; }
|
1973
|
-
if (
|
1974
|
-
absoluteFilePath =
|
1957
|
+
if (core_imports_2._.isArray(absoluteFilePath)) {
|
1958
|
+
absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
|
1975
1959
|
}
|
1976
1960
|
absoluteFilePath = absoluteFilePath;
|
1977
1961
|
if (!core_imports_1.fse.existsSync(absoluteFilePath)) {
|
@@ -2005,8 +1989,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2005
1989
|
HelpersCore.prototype.readJson = function (absoluteFilePath, defaultValue, useJson5) {
|
2006
1990
|
if (defaultValue === void 0) { defaultValue = {}; }
|
2007
1991
|
if (useJson5 === void 0) { useJson5 = false; }
|
2008
|
-
if (
|
2009
|
-
absoluteFilePath =
|
1992
|
+
if (core_imports_2._.isArray(absoluteFilePath)) {
|
1993
|
+
absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
|
2010
1994
|
}
|
2011
1995
|
absoluteFilePath = absoluteFilePath;
|
2012
1996
|
if (!core_imports_1.fse.existsSync(absoluteFilePath)) {
|
@@ -2041,7 +2025,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2041
2025
|
*/
|
2042
2026
|
HelpersCore.prototype.parse = function (jsonInstring, useJson5) {
|
2043
2027
|
if (useJson5 === void 0) { useJson5 = false; }
|
2044
|
-
if (!
|
2028
|
+
if (!core_imports_2._.isString(jsonInstring)) {
|
2045
2029
|
index_1.Helpers.log(jsonInstring);
|
2046
2030
|
index_1.Helpers.warn("[taon-core] Trying to parse no a string...");
|
2047
2031
|
return jsonInstring;
|
@@ -2063,7 +2047,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2063
2047
|
return tslib_1.__generator(this, function (_a) {
|
2064
2048
|
switch (_a.label) {
|
2065
2049
|
case 0:
|
2066
|
-
if (!fn || !
|
2050
|
+
if (!fn || !core_imports_2._.isFunction(fn)) {
|
2067
2051
|
index_1.Helpers.error("".concat(executionType, " wrapper: \"").concat(fn, "\" is not a function."));
|
2068
2052
|
process.exit(1);
|
2069
2053
|
}
|
@@ -2095,8 +2079,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2095
2079
|
HelpersCore.prototype.writeFile = function (absoluteFilePath, input,
|
2096
2080
|
//#endregion
|
2097
2081
|
options) {
|
2098
|
-
if (
|
2099
|
-
absoluteFilePath =
|
2082
|
+
if (core_imports_2._.isArray(absoluteFilePath)) {
|
2083
|
+
absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
|
2100
2084
|
}
|
2101
2085
|
absoluteFilePath = absoluteFilePath;
|
2102
2086
|
// Helpers.info(`[taon-core] writeFile: ${absoluteFilePath}`);
|
@@ -2115,9 +2099,9 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2115
2099
|
var _a = options || {}, preventParentFile = _a.preventParentFile, overrideSameFile = _a.overrideSameFile;
|
2116
2100
|
var dontWriteSameFile = !overrideSameFile;
|
2117
2101
|
if (preventParentFile) {
|
2118
|
-
if (index_1.Helpers.isFile(
|
2119
|
-
core_imports_1.fse.existsSync(
|
2120
|
-
core_imports_1.fse.unlinkSync(
|
2102
|
+
if (index_1.Helpers.isFile(core_imports_2.path.dirname(absoluteFilePath)) &&
|
2103
|
+
core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
|
2104
|
+
core_imports_1.fse.unlinkSync(core_imports_2.path.dirname(absoluteFilePath));
|
2121
2105
|
}
|
2122
2106
|
}
|
2123
2107
|
if (core_imports_1.fse.existsSync(absoluteFilePath) &&
|
@@ -2125,17 +2109,17 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2125
2109
|
index_1.Helpers.warn("[taon-core] Trying to write file content into directory: ".concat(absoluteFilePath));
|
2126
2110
|
return false;
|
2127
2111
|
}
|
2128
|
-
if (!core_imports_1.fse.existsSync(
|
2129
|
-
index_1.Helpers.mkdirp(
|
2112
|
+
if (!core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
|
2113
|
+
index_1.Helpers.mkdirp(core_imports_2.path.dirname(absoluteFilePath));
|
2130
2114
|
}
|
2131
2115
|
if (index_1.Helpers.isBuffer(input)) {
|
2132
2116
|
core_imports_1.fse.writeFileSync(absoluteFilePath, input);
|
2133
2117
|
return true;
|
2134
2118
|
}
|
2135
|
-
if (
|
2119
|
+
if (core_imports_2._.isObject(input)) {
|
2136
2120
|
input = index_1.Helpers.stringify(input);
|
2137
2121
|
}
|
2138
|
-
else if (!
|
2122
|
+
else if (!core_imports_2._.isString(input)) {
|
2139
2123
|
input = '';
|
2140
2124
|
}
|
2141
2125
|
if (dontWriteSameFile) {
|
@@ -2160,19 +2144,19 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2160
2144
|
* wrapper for fs.writeFileSync
|
2161
2145
|
*/
|
2162
2146
|
HelpersCore.prototype.writeJson = function (absoluteFilePath, input, optoins) {
|
2163
|
-
if (
|
2164
|
-
absoluteFilePath =
|
2147
|
+
if (core_imports_2._.isArray(absoluteFilePath)) {
|
2148
|
+
absoluteFilePath = core_imports_2.path.join.apply(this, absoluteFilePath);
|
2165
2149
|
}
|
2166
2150
|
absoluteFilePath = absoluteFilePath;
|
2167
2151
|
var _a = optoins || {}, preventParentFile = _a.preventParentFile, writeJson5 = _a.writeJson5;
|
2168
2152
|
if (preventParentFile) {
|
2169
|
-
if (index_1.Helpers.isFile(
|
2170
|
-
core_imports_1.fse.existsSync(
|
2171
|
-
core_imports_1.fse.unlinkSync(
|
2153
|
+
if (index_1.Helpers.isFile(core_imports_2.path.dirname(absoluteFilePath)) &&
|
2154
|
+
core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
|
2155
|
+
core_imports_1.fse.unlinkSync(core_imports_2.path.dirname(absoluteFilePath));
|
2172
2156
|
}
|
2173
2157
|
}
|
2174
|
-
if (!core_imports_1.fse.existsSync(
|
2175
|
-
index_1.Helpers.mkdirp(
|
2158
|
+
if (!core_imports_1.fse.existsSync(core_imports_2.path.dirname(absoluteFilePath))) {
|
2159
|
+
index_1.Helpers.mkdirp(core_imports_2.path.dirname(absoluteFilePath));
|
2176
2160
|
}
|
2177
2161
|
if (writeJson5) {
|
2178
2162
|
var existedContent = index_1.Helpers.readFile(absoluteFilePath) || '{}';
|
@@ -2213,8 +2197,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2213
2197
|
* @returns absoulte pathes to folders from path
|
2214
2198
|
*/
|
2215
2199
|
HelpersCore.prototype.foldersFrom = function (pathToFolder, options) {
|
2216
|
-
if (
|
2217
|
-
pathToFolder = (0,
|
2200
|
+
if (core_imports_2._.isArray(pathToFolder)) {
|
2201
|
+
pathToFolder = (0, core_imports_2.crossPlatformPath)(pathToFolder);
|
2218
2202
|
}
|
2219
2203
|
if (!index_1.Helpers.exists(pathToFolder)) {
|
2220
2204
|
return [];
|
@@ -2231,7 +2215,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2231
2215
|
var file = files_1_1.value;
|
2232
2216
|
if (file.isDirectory() &&
|
2233
2217
|
!index_1.Helpers.isSymlinkFileExitedOrUnexisted([folderPath, file.name])) {
|
2234
|
-
var dirPath = (0,
|
2218
|
+
var dirPath = (0, core_imports_2.crossPlatformPath)([folderPath, file.name]);
|
2235
2219
|
// console.log('dirPath', dirPath)
|
2236
2220
|
directories.push(dirPath);
|
2237
2221
|
// If recursive, read the directory found
|
@@ -2266,15 +2250,15 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2266
2250
|
*/
|
2267
2251
|
HelpersCore.prototype.linksToFoldersFrom = function (pathToFolder, outputRealPath) {
|
2268
2252
|
if (outputRealPath === void 0) { outputRealPath = false; }
|
2269
|
-
if (
|
2270
|
-
pathToFolder =
|
2253
|
+
if (core_imports_2._.isArray(pathToFolder)) {
|
2254
|
+
pathToFolder = core_imports_2.path.join.apply(core_imports_2.path, tslib_1.__spreadArray([], tslib_1.__read(pathToFolder), false));
|
2271
2255
|
}
|
2272
2256
|
if (!index_1.Helpers.exists(pathToFolder)) {
|
2273
2257
|
return [];
|
2274
2258
|
}
|
2275
2259
|
return (core_imports_1.fse
|
2276
2260
|
.readdirSync(pathToFolder)
|
2277
|
-
.map(function (f) { return
|
2261
|
+
.map(function (f) { return core_imports_2.path.join(pathToFolder, f); })
|
2278
2262
|
.filter(function (f) { return core_imports_1.fse.existsSync(f) && core_imports_1.fse.lstatSync(f).isSymbolicLink(); })
|
2279
2263
|
.map(function (f) {
|
2280
2264
|
var realPath = core_imports_1.fse.realpathSync(f);
|
@@ -2290,7 +2274,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2290
2274
|
})
|
2291
2275
|
.filter(function (f) { return !!f; })
|
2292
2276
|
// @ts-ignore
|
2293
|
-
.map(function (f) { return (0,
|
2277
|
+
.map(function (f) { return (0, core_imports_2.crossPlatformPath)(f); }));
|
2294
2278
|
};
|
2295
2279
|
//#endregion
|
2296
2280
|
//#endregion
|
@@ -2304,15 +2288,15 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2304
2288
|
// if (_.isUndefined(options.linksOnlyTo)) {
|
2305
2289
|
// options.linksOnlyTo = 'both';
|
2306
2290
|
// }
|
2307
|
-
if (
|
2308
|
-
pathToFolder =
|
2291
|
+
if (core_imports_2._.isArray(pathToFolder)) {
|
2292
|
+
pathToFolder = core_imports_2.path.join.apply(core_imports_2.path, tslib_1.__spreadArray([], tslib_1.__read(pathToFolder), false));
|
2309
2293
|
}
|
2310
2294
|
if (!index_1.Helpers.exists(pathToFolder)) {
|
2311
2295
|
return [];
|
2312
2296
|
}
|
2313
2297
|
return core_imports_1.fse
|
2314
2298
|
.readdirSync(pathToFolder)
|
2315
|
-
.map(function (f) { return
|
2299
|
+
.map(function (f) { return core_imports_2.path.join(pathToFolder, f); })
|
2316
2300
|
.filter(function (f) {
|
2317
2301
|
var res = false;
|
2318
2302
|
if (index_1.Helpers.isExistedSymlink(f)) {
|
@@ -2321,7 +2305,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2321
2305
|
}
|
2322
2306
|
return res;
|
2323
2307
|
})
|
2324
|
-
.map(function (f) { return (0,
|
2308
|
+
.map(function (f) { return (0, core_imports_2.crossPlatformPath)(f); });
|
2325
2309
|
};
|
2326
2310
|
//#endregion
|
2327
2311
|
//#endregion
|
@@ -2334,8 +2318,8 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2334
2318
|
var _this = this;
|
2335
2319
|
if (recrusive === void 0) { recrusive = false; }
|
2336
2320
|
if (incudeUnexistedLinks === void 0) { incudeUnexistedLinks = false; }
|
2337
|
-
if (
|
2338
|
-
pathToFolder =
|
2321
|
+
if (core_imports_2._.isArray(pathToFolder)) {
|
2322
|
+
pathToFolder = core_imports_2.path.join.apply(core_imports_2.path, tslib_1.__spreadArray([], tslib_1.__read(pathToFolder), false));
|
2339
2323
|
}
|
2340
2324
|
if (!index_1.Helpers.exists(pathToFolder)) {
|
2341
2325
|
return [];
|
@@ -2346,7 +2330,7 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2346
2330
|
if (recrusive) {
|
2347
2331
|
var all = core_imports_1.fse
|
2348
2332
|
.readdirSync(pathToFolder)
|
2349
|
-
.map(function (f) { return (0,
|
2333
|
+
.map(function (f) { return (0, core_imports_2.crossPlatformPath)([pathToFolder, f]); });
|
2350
2334
|
var folders_1 = [];
|
2351
2335
|
var files = all.filter(function (f) {
|
2352
2336
|
if (core_imports_1.fse.lstatSync(f).isDirectory()) {
|
@@ -2359,11 +2343,11 @@ var HelpersCore = /** @class */ (function (_super) {
|
|
2359
2343
|
.map(function (f) { return _this.filesFrom(f, recrusive); })
|
2360
2344
|
.reduce(function (a, b) {
|
2361
2345
|
return a.concat(b);
|
2362
|
-
}, [])), false).map(function (f) { return (0,
|
2346
|
+
}, [])), false).map(function (f) { return (0, core_imports_2.crossPlatformPath)(f); });
|
2363
2347
|
}
|
2364
2348
|
return core_imports_1.fse
|
2365
2349
|
.readdirSync(pathToFolder)
|
2366
|
-
.map(function (f) { return (0,
|
2350
|
+
.map(function (f) { return (0, core_imports_2.crossPlatformPath)(core_imports_2.path.join(pathToFolder, f)); })
|
2367
2351
|
.filter(function (f) {
|
2368
2352
|
return !core_imports_1.fse.lstatSync(f).isDirectory();
|
2369
2353
|
});
|