@@ -8,27 +8,27 @@ const unzipper = require('unzipper')
8
8
const rimraf = require ( 'rimraf' )
9
9
10
10
function dirParamToPath ( dirParam ) {
11
- switch ( dirParam ) {
12
- case 'plugins_repo' :
13
- return config . pluginsRepoDir
14
- case 'plugins' :
15
- return config . pluginsDir
16
- case 'rootDir' :
17
- return config . rootDir
11
+ switch ( dirParam ) {
12
+ case 'plugins_repo' :
13
+ return config . pluginsRepoDir
14
+ case 'plugins' :
15
+ return config . pluginsDir
16
+ case 'rootDir' :
17
+ return config . rootDir
18
18
}
19
19
return null
20
20
}
21
21
22
22
const commands = {
23
- cleanExceptDefault : function ( args ) {
23
+ cleanExceptDefault : function ( args ) {
24
24
let plugins = [ ]
25
25
try {
26
26
plugins = args . split ( ',' )
27
- } catch ( e ) {
27
+ } catch ( e ) {
28
28
console . error ( 'The args passed is invalid or undefined. All plugins will be removed.' )
29
29
}
30
30
31
- const pluginsDir = dirParamToPath ( 'plugins' )
31
+ const pluginsDir = dirParamToPath ( 'plugins' )
32
32
33
33
fse . readdirSync ( pluginsDir )
34
34
. map ( file => path . join ( pluginsDir , file ) )
@@ -37,7 +37,7 @@ const commands = {
37
37
//.filter(path => fse.readdirSync(path).length === 0)
38
38
. map ( path => rimraf . sync ( path ) )
39
39
} ,
40
- resetPluginConfig : function ( ) {
40
+ resetPluginConfig : function ( ) {
41
41
const pluginsDir = dirParamToPath ( 'plugins' )
42
42
const configJson = [ ]
43
43
@@ -48,7 +48,7 @@ const commands = {
48
48
. map ( path => configJson . push ( this . createPluginEntry ( this . getLastFolderName ( path ) ) ) )
49
49
fse . writeFileSync ( path . join ( dirParamToPath ( 'rootDir' ) , 'plugins.config.json' ) , JSON . stringify ( configJson , null , 2 ) )
50
50
} ,
51
- addPlugin : function ( sourcePath ) {
51
+ addPlugin : function ( sourcePath ) {
52
52
const pluginsPath = dirParamToPath ( 'plugins' )
53
53
54
54
if ( ! fse . existsSync ( sourcePath ) ) {
@@ -70,12 +70,12 @@ const commands = {
70
70
fse . writeFileSync ( path . join ( dirParamToPath ( 'rootDir' ) , 'plugins.config.json' ) , JSON . stringify ( pluginsObj , null , 2 ) )
71
71
72
72
} ,
73
- removePlugin : function ( pluginName ) {
73
+ removePlugin : function ( pluginName ) {
74
74
try {
75
75
const pluginsPath = dirParamToPath ( 'plugins' )
76
76
const pluginDirName = path . dirname ( pluginsObj . filter ( ele => ele . key === pluginName ) [ 0 ] . metadataFile ) . replace ( './' , '' )
77
77
const pluginPathInRepo = path . join ( pluginsPath , pluginDirName )
78
-
78
+
79
79
if ( fse . existsSync ( pluginPathInRepo ) ) {
80
80
rimraf . sync ( pluginPathInRepo )
81
81
fse . writeFileSync (
@@ -87,24 +87,24 @@ const commands = {
87
87
console . error ( 'Error in enabling plugin. Check the plugin keys entered in args.' )
88
88
}
89
89
} ,
90
- createPluginEntry : function ( pluginKey ) {
90
+ createPluginEntry : function ( pluginKey ) {
91
91
const pluginObj = { }
92
92
pluginObj . key = pluginKey
93
- pluginObj . metadataFile = './' + pluginKey + '/plugin-metadata'
93
+ pluginObj . metadataFile = './' + pluginKey + '/plugin-metadata'
94
94
return pluginObj
95
95
} ,
96
- showAllPlugins : function ( ) {
97
- if ( pluginsObj . length == 0 ) {
96
+ showAllPlugins : function ( ) {
97
+ if ( pluginsObj . length == 0 ) {
98
98
console . log ( '- No Plugin in repo.' )
99
99
return
100
100
}
101
101
console . log ( 'Following plugins are present.' )
102
102
pluginsObj . forEach ( ele => {
103
- console . log ( '- ' + ele . key )
103
+ console . log ( '- ' + ele . key )
104
104
} )
105
105
} ,
106
- getLastFolderName : function ( path ) {
107
- return path . replace ( / \\ / g, '/' ) . split ( '/' ) . filter ( function ( el ) {
106
+ getLastFolderName : function ( path ) {
107
+ return path . replace ( / \\ / g, '/' ) . split ( '/' ) . filter ( function ( el ) {
108
108
return el . trim ( ) . length > 0
109
109
} ) . pop ( )
110
110
}
@@ -117,7 +117,7 @@ program
117
117
. option ( '-ap, --addPlugin []' )
118
118
. option ( '-rp, --removePlugin []' )
119
119
. parse ( process . argv )
120
- const options = program . opts ( ) ;
120
+ const options = program . opts ( ) ;
121
121
for ( const commandName in commands ) {
122
122
// eslint-disable-next-line no-prototype-builtins
123
123
if ( commands . hasOwnProperty ( commandName ) && options [ commandName ] ) {
0 commit comments