@zwa73/utils 1.0.96 → 1.0.99
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/dist/UtilFileTools.js
CHANGED
|
@@ -217,7 +217,10 @@ var UtilFT;
|
|
|
217
217
|
* @returns 文件绝对路径数组
|
|
218
218
|
*/
|
|
219
219
|
function fileSearchGlob(globPattern, ignore) {
|
|
220
|
-
|
|
220
|
+
const fixedPath = typeof globPattern === "string"
|
|
221
|
+
? path.posix.normalize(globPattern)
|
|
222
|
+
: globPattern.map((p) => path.posix.normalize(p));
|
|
223
|
+
return (0, glob_1.globSync)(fixedPath, { ignore, absolute: true });
|
|
221
224
|
}
|
|
222
225
|
UtilFT.fileSearchGlob = fileSearchGlob;
|
|
223
226
|
/**
|
package/dist/UtilFunctions.d.ts
CHANGED
|
@@ -175,19 +175,20 @@ export declare class UtilFunc {
|
|
|
175
175
|
/**移除多行字符串中每行开始的最小空格数。
|
|
176
176
|
*
|
|
177
177
|
* @param strings - 需要处理的多行字符串模板。
|
|
178
|
-
* @param
|
|
179
|
-
* @returns
|
|
178
|
+
* @param values - 插入模板字符串中的值。
|
|
179
|
+
* @returns 返回处理后的字符串,每行开始的空格数已被最小化。
|
|
180
180
|
*
|
|
181
181
|
* @example
|
|
182
|
+
* const name = 'World';
|
|
182
183
|
* const str = dedent`
|
|
183
184
|
* Hello,
|
|
184
|
-
*
|
|
185
|
+
* ${name}!
|
|
185
186
|
* `;
|
|
186
187
|
* console.log(str);
|
|
187
188
|
* // 输出:
|
|
188
189
|
* // Hello,
|
|
189
190
|
* // World!
|
|
190
191
|
*/
|
|
191
|
-
static dedent(strings: TemplateStringsArray,
|
|
192
|
+
static dedent(strings: TemplateStringsArray, ...values: any[]): string;
|
|
192
193
|
}
|
|
193
194
|
export {};
|
package/dist/UtilFunctions.js
CHANGED
|
@@ -497,25 +497,25 @@ class UtilFunc {
|
|
|
497
497
|
/**移除多行字符串中每行开始的最小空格数。
|
|
498
498
|
*
|
|
499
499
|
* @param strings - 需要处理的多行字符串模板。
|
|
500
|
-
* @param
|
|
501
|
-
* @returns
|
|
500
|
+
* @param values - 插入模板字符串中的值。
|
|
501
|
+
* @returns 返回处理后的字符串,每行开始的空格数已被最小化。
|
|
502
502
|
*
|
|
503
503
|
* @example
|
|
504
|
+
* const name = 'World';
|
|
504
505
|
* const str = dedent`
|
|
505
506
|
* Hello,
|
|
506
|
-
*
|
|
507
|
+
* ${name}!
|
|
507
508
|
* `;
|
|
508
509
|
* console.log(str);
|
|
509
510
|
* // 输出:
|
|
510
511
|
* // Hello,
|
|
511
512
|
* // World!
|
|
512
513
|
*/
|
|
513
|
-
static dedent(strings,
|
|
514
|
-
const str = strings.
|
|
514
|
+
static dedent(strings, ...values) {
|
|
515
|
+
const str = strings.reduce((result, string, i) => result + string + (values[i] || ''), '');
|
|
515
516
|
const lines = str.split('\n');
|
|
516
517
|
const minIndent = Math.min(...lines.filter(line => line.trim() !== '').map(line => line.search(/\S/)));
|
|
517
|
-
|
|
518
|
-
return trim ? result.trim() : result;
|
|
518
|
+
return lines.map(line => line.slice(minIndent)).join('\n');
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
521
|
exports.UtilFunc = UtilFunc;
|
package/package.json
CHANGED
package/src/UtilFileTools.ts
CHANGED
|
@@ -222,7 +222,10 @@ export function fileSearchRegex(folder: string, traitRegex: string) {
|
|
|
222
222
|
* @returns 文件绝对路径数组
|
|
223
223
|
*/
|
|
224
224
|
export function fileSearchGlob(globPattern:string|string[],ignore?:string|string[]){
|
|
225
|
-
|
|
225
|
+
const fixedPath = typeof globPattern === "string"
|
|
226
|
+
? path.posix.normalize(globPattern)
|
|
227
|
+
: globPattern.map((p)=>path.posix.normalize(p));
|
|
228
|
+
return globSync(fixedPath,{ignore,absolute:true});
|
|
226
229
|
}
|
|
227
230
|
/**
|
|
228
231
|
* @deprecated 请使用 fileSearchRegex 或 fileSearchGlob
|
package/src/UtilFunctions.ts
CHANGED
|
@@ -562,27 +562,28 @@ static bindTo<K extends Keyable, V, B extends {} = {}>
|
|
|
562
562
|
/**移除多行字符串中每行开始的最小空格数。
|
|
563
563
|
*
|
|
564
564
|
* @param strings - 需要处理的多行字符串模板。
|
|
565
|
-
* @param
|
|
566
|
-
* @returns
|
|
565
|
+
* @param values - 插入模板字符串中的值。
|
|
566
|
+
* @returns 返回处理后的字符串,每行开始的空格数已被最小化。
|
|
567
567
|
*
|
|
568
568
|
* @example
|
|
569
|
+
* const name = 'World';
|
|
569
570
|
* const str = dedent`
|
|
570
571
|
* Hello,
|
|
571
|
-
*
|
|
572
|
+
* ${name}!
|
|
572
573
|
* `;
|
|
573
574
|
* console.log(str);
|
|
574
575
|
* // 输出:
|
|
575
576
|
* // Hello,
|
|
576
577
|
* // World!
|
|
577
578
|
*/
|
|
578
|
-
static dedent(strings: TemplateStringsArray,
|
|
579
|
-
const str = strings.
|
|
579
|
+
static dedent(strings: TemplateStringsArray, ...values: any[]): string {
|
|
580
|
+
const str = strings.reduce((result, string, i) => result + string + (values[i] || ''), '');
|
|
580
581
|
const lines = str.split('\n');
|
|
581
582
|
const minIndent = Math.min(
|
|
582
583
|
...lines.filter(line => line.trim() !== '').map(line => line.search(/\S/))
|
|
583
584
|
);
|
|
584
|
-
|
|
585
|
-
return trim ? result.trim() : result;
|
|
585
|
+
return lines.map(line => line.slice(minIndent)).join('\n');
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
+
|
|
588
589
|
}
|