@zwa73/utils 1.0.17 → 1.0.19

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.
@@ -32,21 +32,22 @@ export declare function pathExistsSync(filePath: string): boolean;
32
32
  export declare function createPath(filePath: string, isDir?: boolean): Promise<boolean>;
33
33
  /**路径不存在时创建路径 以path.sep结尾时创建文件夹 同步
34
34
  * @param {string} filePath - 待创建的路径
35
- * @param {boolean} isDir - 强制创建一个文件夹
35
+ * @param {boolean} isDir - 强制验证一个文件夹
36
36
  * @returns {boolean} - 是否成功创建
37
37
  */
38
38
  export declare function createPathSync(filePath: string, isDir?: boolean): boolean;
39
39
  /**确保路径存在 不存在时创建 异步
40
40
  * @async
41
41
  * @param {string} filePath - 待验证的路径
42
+ * @param {boolean} isDir - 强制验证一个文件夹
42
43
  * @returns {Promise<boolean>} - 是否成功执行 创建或已存在
43
44
  */
44
- export declare function ensurePathExists(filePath: string): Promise<boolean>;
45
+ export declare function ensurePathExists(filePath: string, isDir?: boolean): Promise<boolean>;
45
46
  /**确保路径存在 不存在时创建 同步
46
47
  * @param {string} filePath - 待验证的路径
47
48
  * @returns {boolean} - 是否成功执行 创建或已存在
48
49
  */
49
- export declare function ensurePathExistsSync(filePath: string): boolean;
50
+ export declare function ensurePathExistsSync(filePath: string, isDir?: boolean): boolean;
50
51
  /**加载json文件 同步
51
52
  * Object (string)
52
53
  * @param {string} filePath - 文件路径
@@ -82,7 +82,7 @@ async function createPath(filePath, isDir) {
82
82
  exports.createPath = createPath;
83
83
  /**路径不存在时创建路径 以path.sep结尾时创建文件夹 同步
84
84
  * @param {string} filePath - 待创建的路径
85
- * @param {boolean} isDir - 强制创建一个文件夹
85
+ * @param {boolean} isDir - 强制验证一个文件夹
86
86
  * @returns {boolean} - 是否成功创建
87
87
  */
88
88
  function createPathSync(filePath, isDir) {
@@ -107,22 +107,23 @@ exports.createPathSync = createPathSync;
107
107
  /**确保路径存在 不存在时创建 异步
108
108
  * @async
109
109
  * @param {string} filePath - 待验证的路径
110
+ * @param {boolean} isDir - 强制验证一个文件夹
110
111
  * @returns {Promise<boolean>} - 是否成功执行 创建或已存在
111
112
  */
112
- async function ensurePathExists(filePath) {
113
+ async function ensurePathExists(filePath, isDir) {
113
114
  if (await pathExists(filePath))
114
115
  return true;
115
- return await createPath(filePath);
116
+ return await createPath(filePath, isDir);
116
117
  }
117
118
  exports.ensurePathExists = ensurePathExists;
118
119
  /**确保路径存在 不存在时创建 同步
119
120
  * @param {string} filePath - 待验证的路径
120
121
  * @returns {boolean} - 是否成功执行 创建或已存在
121
122
  */
122
- function ensurePathExistsSync(filePath) {
123
+ function ensurePathExistsSync(filePath, isDir) {
123
124
  if (pathExistsSync(filePath))
124
125
  return true;
125
- return createPathSync(filePath);
126
+ return createPathSync(filePath, isDir);
126
127
  }
127
128
  exports.ensurePathExistsSync = ensurePathExistsSync;
128
129
  /**加载json文件 同步
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -83,7 +83,7 @@ export async function createPath(filePath: string, isDir?:boolean):Promise<boole
83
83
 
84
84
  /**路径不存在时创建路径 以path.sep结尾时创建文件夹 同步
85
85
  * @param {string} filePath - 待创建的路径
86
- * @param {boolean} isDir - 强制创建一个文件夹
86
+ * @param {boolean} isDir - 强制验证一个文件夹
87
87
  * @returns {boolean} - 是否成功创建
88
88
  */
89
89
  export function createPathSync(filePath: string, isDir?:boolean):boolean{
@@ -109,22 +109,23 @@ export function createPathSync(filePath: string, isDir?:boolean):boolean{
109
109
  /**确保路径存在 不存在时创建 异步
110
110
  * @async
111
111
  * @param {string} filePath - 待验证的路径
112
+ * @param {boolean} isDir - 强制验证一个文件夹
112
113
  * @returns {Promise<boolean>} - 是否成功执行 创建或已存在
113
114
  */
114
- export async function ensurePathExists(filePath: string):Promise<boolean>{
115
+ export async function ensurePathExists(filePath: string, isDir?:boolean):Promise<boolean>{
115
116
  if(await pathExists(filePath))
116
117
  return true;
117
- return await createPath(filePath);
118
+ return await createPath(filePath,isDir);
118
119
  }
119
120
 
120
121
  /**确保路径存在 不存在时创建 同步
121
122
  * @param {string} filePath - 待验证的路径
122
123
  * @returns {boolean} - 是否成功执行 创建或已存在
123
124
  */
124
- export function ensurePathExistsSync(filePath: string):boolean{
125
+ export function ensurePathExistsSync(filePath: string, isDir?:boolean):boolean{
125
126
  if(pathExistsSync(filePath))
126
127
  return true;
127
- return createPathSync(filePath);
128
+ return createPathSync(filePath,isDir);
128
129
  }
129
130
 
130
131
  /**加载json文件 同步