@kengic/uni 0.6.3-beta.58 → 0.6.3-beta.59

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kengic/uni",
3
- "version": "0.6.3-beta.58",
3
+ "version": "0.6.3-beta.59",
4
4
  "scripts": {
5
5
  "postinstall": "node ./script/postinstall.mjs"
6
6
  },
@@ -4,18 +4,30 @@ import fs from 'fs';
4
4
  * 获取当前时间.
5
5
  */
6
6
  function now() {
7
- return new Date(Date.now() + 1000 * 60 * 60 * 8).toISOString().substring(0, 23).replace('T', ' ');
7
+ return `[${new Date(Date.now() + 1000 * 60 * 60 * 8).toISOString().substring(0, 23).replace('T', ' ')}] [@kengic/uni] POST INSTALL | `;
8
8
  }
9
9
 
10
10
  /**
11
11
  * 项目目录.
12
12
  */
13
- const PROJECT_DIR = '../../../../../..';
13
+ const PROJECT_DIR = '../../../../../../..';
14
14
 
15
- console.log(`[${now()}] [@kengic/uni] POST INSTALL`);
16
- console.log(`[${now()}] [@kengic/uni] POST INSTALL ${process.cwd()}`);
15
+ console.log(`${now()}`);
16
+ console.log(`${now()}${process.cwd()}`);
17
17
 
18
- const { default: json01 } = await import(`${PROJECT_DIR}/package.json`);
19
- console.log('333', json01.name);
18
+ let json01 = null;
20
19
 
21
- fs.writeFileSync(`${PROJECT_DIR}/package.json`, `${JSON.stringify(json01, null, 4)}\n`, {});
20
+ try {
21
+ console.log(`${now()}开始读取 package.json`);
22
+ json01 = (await import(`${PROJECT_DIR}/package.json`)).default;
23
+ console.log(`${now()}成功读取 package.json`);
24
+ } catch (e) {
25
+ console.log(`${now()}失败读取 package.json`);
26
+ console.error(e);
27
+ }
28
+
29
+ if (json01) {
30
+ console.log(`${now()}开始写入 package.json`);
31
+ fs.writeFileSync(`${PROJECT_DIR}/package.json`, `${JSON.stringify(json01, null, 4)}\n`, {});
32
+ console.log(`${now()}成功写入 package.json`);
33
+ }