Skip to content

Commit 49db785

Browse files
committed
feat(@142vip/utils): 拓展mkdirSync等方法 (#542)
1 parent b6d345b commit 49db785

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/utils/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export enum OPEN_SOURCE_ADDRESS {
4343

4444
// 域名
4545
HOME_PAGE_DOMAIN_VIP = 'https://142vip.cn',
46+
HOME_PAGE_DOMAIN_408 = 'https://408.142vip.cn',
47+
// HOME_PAGE_DOMAIN_JSC = 'https://js.142vip.cn',
4648

4749
// 证书
4850
LICENCE_GITHUB = 'https://github.com/142vip/LICENSE',

packages/utils/src/core/nodejs.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ function getProcessEnv(key: string): string | undefined {
4747
return undefined
4848
}
4949

50+
/**
51+
* 设置当前京城环境变量
52+
* @param key 键
53+
* @param value 值
54+
*/
5055
function setProcessEnv(key: string, value: string): void {
5156
process.env[key] = value
5257
}
@@ -171,7 +176,7 @@ function readdirSync(path: PathLike, options?: {
171176
encoding: BufferEncoding | null
172177
withFileTypes?: false | undefined
173178
recursive?: boolean | undefined
174-
} | BufferEncoding | null) {
179+
} | BufferEncoding | null): string[] {
175180
return fs.readdirSync(path, options)
176181
}
177182
/**
@@ -183,10 +188,23 @@ function writeFileByUTF8(filePath: PathLike, data:
183188
return writeFileSync(filePath, data, 'utf-8')
184189
}
185190

191+
/**
192+
* 判断是否为Buffer类型
193+
* @param data 输入数据
194+
* @return boolean
195+
*/
186196
function isBuffer(data: object): boolean {
187197
return Buffer.isBuffer(data)
188198
}
189199

200+
/**
201+
* 创建目录
202+
* @param path 目录路径
203+
*/
204+
function mkdirSync(path: PathLike): void {
205+
fs.mkdirSync(path)
206+
}
207+
190208
/**
191209
* 打印标准的Node开发环境信息
192210
*/
@@ -269,6 +287,7 @@ export const VipNodeJS = {
269287
readdirSync,
270288
readFileToStrByUTF8,
271289
writeFileByUTF8,
290+
mkdirSync,
272291
pathJoin,
273292
pathResolve,
274293
pathDirname,

0 commit comments

Comments
 (0)