Skip to content

Commit 264d2ca

Browse files
committed
fix: Compatible with fs.copyFileSync() below node 8.5.0
1 parent 5aac5ca commit 264d2ca

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"dependencies": {
2525
"axios": "^0.19.0",
2626
"colors": "^1.3.3",
27+
"fs-extra": "^8.1.0",
2728
"glob": "^7.1.4",
2829
"lodash": "^4.17.15",
2930
"minimist": "^1.2.0",
@@ -32,6 +33,7 @@
3233
"xml2js": "^0.4.19"
3334
},
3435
"devDependencies": {
36+
"@types/fs-extra": "^8.0.0",
3537
"@types/glob": "^7.1.1",
3638
"@types/lodash": "^4.14.137",
3739
"@types/minimist": "^1.2.0",

src/commands/createJson.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
import path from 'path';
44
import fs from 'fs';
5+
import fse from 'fs-extra';
56
import colors from 'colors';
67

78
const targetFile = path.resolve('iconfont.json');
89

910
if (fs.existsSync(targetFile)) {
1011
console.error(colors.red('File "iconfont.json" was created before.'));
1112
} else {
12-
fs.copyFileSync(path.join(__dirname, '../libs/iconfont.json'), targetFile);
13+
// fs.copyFileSync only can be used above node v8.5.0+
14+
fse.copySync(path.join(__dirname, '../libs/iconfont.json'), targetFile);
1315
console.log(colors.green('File "iconfont.json" is created now. We recommend you add it to version control.'));
1416
}

yarn.lock

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
resolved "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
88
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==
99

10+
"@types/fs-extra@^8.0.0":
11+
version "8.0.0"
12+
resolved "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.0.0.tgz#d3e2c313ca29f95059f198dd60d1f774642d4b25"
13+
integrity sha512-bCtL5v9zdbQW86yexOlXWTEGvLNqWxMFyi7gQA7Gcthbezr2cPSOb8SkESVKA937QD5cIwOFLDFt0MQoXOEr9Q==
14+
dependencies:
15+
"@types/node" "*"
16+
1017
"@types/glob@^7.1.1":
1118
version "7.1.1"
1219
resolved "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz#aa59a1c6e3fbc421e07ccd31a944c30eba521575"
@@ -128,6 +135,15 @@ follow-redirects@1.5.10:
128135
dependencies:
129136
debug "=3.1.0"
130137

138+
fs-extra@^8.1.0:
139+
version "8.1.0"
140+
resolved "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
141+
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
142+
dependencies:
143+
graceful-fs "^4.2.0"
144+
jsonfile "^4.0.0"
145+
universalify "^0.1.0"
146+
131147
fs.realpath@^1.0.0:
132148
version "1.0.0"
133149
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -145,6 +161,11 @@ glob@^7.1.4:
145161
once "^1.3.0"
146162
path-is-absolute "^1.0.0"
147163

164+
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
165+
version "4.2.2"
166+
resolved "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.2.tgz#6f0952605d0140c1cfdb138ed005775b92d67b02"
167+
integrity sha512-IItsdsea19BoLC7ELy13q1iJFNmd7ofZH5+X/pJr90/nRoPEX0DJo1dHDbgtYWOhJhcCgMDTOw84RZ72q6lB+Q==
168+
148169
inflight@^1.0.4:
149170
version "1.0.6"
150171
resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
@@ -168,6 +189,13 @@ is-buffer@^2.0.2:
168189
resolved "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
169190
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==
170191

192+
jsonfile@^4.0.0:
193+
version "4.0.0"
194+
resolved "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
195+
integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=
196+
optionalDependencies:
197+
graceful-fs "^4.1.6"
198+
171199
lodash@^4.17.15:
172200
version "4.17.15"
173201
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
@@ -293,6 +321,11 @@ typescript@^3.5.3:
293321
resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
294322
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
295323

324+
universalify@^0.1.0:
325+
version "0.1.2"
326+
resolved "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
327+
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
328+
296329
wrappy@1:
297330
version "1.0.2"
298331
resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

0 commit comments

Comments
 (0)