This repository was archived by the owner on Apr 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +70
-55
lines changed Expand file tree Collapse file tree 2 files changed +70
-55
lines changed Original file line number Diff line number Diff line change 1- const fs = require ( 'fs' )
2- const path = require ( 'path' )
3-
4- function checkInstalled ( target ) {
5- let ret = true
6- try {
7- const resolveModule = require ( path . resolve ( target ) )
8- if ( ! resolveModule ) {
9- ret = false
10- }
11- } catch ( e ) {
12- ret = false
13- }
14- return ret
15- }
16-
17- function exists ( path ) {
18- let ret = true
19- try {
20- fs . accessSync ( path , fs . constants . F_OK )
21- } catch ( e ) {
22- ret = false
23- }
24- return ret
25- }
26-
27- function mkdir ( path ) {
28- let ret = true
29- try {
30- fs . mkdirSync ( path )
31- } catch ( e ) {
32- ret = false
33- }
34- return ret
35- }
36-
37- function writeFile ( path , content ) {
38- let ret = true
39- try {
40- fs . writeFileSync ( path , content , { encoding : 'utf8' } )
41- } catch ( e ) {
42- ret = false
43- }
44- return ret
45- }
46-
47- function readFile ( path ) {
48- let ret = ''
49- try {
50- ret = fs . readFileSync ( path , { encoding : 'utf8' } )
51- } catch ( e ) {
52- ret = ''
53- }
54- return ret
55- }
1+ const {
2+ checkInstalled,
3+ exists,
4+ mkdir,
5+ writeFile,
6+ readFile
7+ } = require ( '../utils' )
568
579module . exports = ( api , options , rootOptions ) => {
5810 const { locale, fallbackLocale, enableInSFC } = options
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' )
2+ const path = require ( 'path' )
3+
4+ function checkInstalled ( target ) {
5+ let ret = true
6+ try {
7+ const resolveModule = require ( path . resolve ( target ) )
8+ if ( ! resolveModule ) {
9+ ret = false
10+ }
11+ } catch ( e ) {
12+ ret = false
13+ }
14+ return ret
15+ }
16+
17+ function exists ( path ) {
18+ let ret = true
19+ try {
20+ fs . accessSync ( path , fs . constants . F_OK )
21+ } catch ( e ) {
22+ ret = false
23+ }
24+ return ret
25+ }
26+
27+ function mkdir ( path ) {
28+ let ret = true
29+ try {
30+ fs . mkdirSync ( path )
31+ } catch ( e ) {
32+ ret = false
33+ }
34+ return ret
35+ }
36+
37+ function writeFile ( path , content ) {
38+ let ret = true
39+ try {
40+ fs . writeFileSync ( path , content , { encoding : 'utf8' } )
41+ } catch ( e ) {
42+ ret = false
43+ }
44+ return ret
45+ }
46+
47+ function readFile ( path ) {
48+ let ret = ''
49+ try {
50+ ret = fs . readFileSync ( path , { encoding : 'utf8' } )
51+ } catch ( e ) {
52+ ret = ''
53+ }
54+ return ret
55+ }
56+
57+ module . exports = {
58+ checkInstalled,
59+ exists,
60+ mkdir,
61+ writeFile,
62+ readFile
63+ }
You can’t perform that action at this time.
0 commit comments