3
3
const plugin_manager = function ( config , configPath ) {
4
4
const path = require ( 'path' ) ;
5
5
const fs = require ( 'fs-extra' ) ;
6
- const util = require ( './utilities ' ) ;
6
+ const logger = require ( './log ' ) ;
7
7
8
8
/**
9
9
* Loads a plugin
@@ -25,12 +25,12 @@ const plugin_manager = function (config, configPath) {
25
25
const pluginPath = path . resolve (
26
26
path . join ( process . cwd ( ) , 'node_modules' , pluginName )
27
27
) ;
28
- console . log ( ' Attempting to load plugin from' , pluginPath ) ;
28
+ logger . debug ( ` Attempting to load plugin from ${ pluginPath } ` ) ;
29
29
try {
30
30
var pluginDirStats = fs . statSync ( pluginPath ) ;
31
31
} catch ( ex ) {
32
- util . error ( pluginName + ' not found, please use npm to install it first.' ) ;
33
- util . error ( pluginName + ' not loaded.' ) ;
32
+ logger . warning ( ` ${ pluginName } not found, use npm to install it first.` ) ;
33
+ logger . warning ( ` ${ pluginName } not loaded.` ) ;
34
34
return ;
35
35
}
36
36
const pluginPathDirExists = pluginDirStats . isDirectory ( ) ;
@@ -63,13 +63,12 @@ const plugin_manager = function (config, configPath) {
63
63
//write config entry back
64
64
fs . outputFileSync ( path . resolve ( configPath ) , JSON . stringify ( diskConfig , null , 2 ) ) ;
65
65
66
- util . debug ( 'Plugin ' + pluginName + ' installed.' ) ;
67
-
68
- //todo, tell them how to uninstall or disable
69
-
66
+ logger . info ( 'Plugin ' + pluginName + ' installed.' ) ;
67
+ logger . info ( 'Plugin configration added to patternlab-config.json.' ) ;
70
68
}
71
69
} catch ( ex ) {
72
- console . log ( ex ) ;
70
+ logger . warning ( `An error occurred during plugin installation for plugin ${ pluginName } ` ) ;
71
+ logger . warning ( ex ) ;
73
72
}
74
73
}
75
74
@@ -91,15 +90,15 @@ const plugin_manager = function (config, configPath) {
91
90
* Not implemented yet
92
91
*/
93
92
function disablePlugin ( pluginName ) {
94
- console . log ( ' disablePlugin not implemented yet. No change made to state of plugin' , pluginName ) ;
93
+ logger . warning ( ` disablePlugin() not implemented yet. No change made to state of plugin ${ pluginName } ` ) ;
95
94
}
96
95
97
96
/**
98
97
* Enables an installed plugin
99
98
* Not implemented yet
100
99
*/
101
100
function enablePlugin ( pluginName ) {
102
- console . log ( ' enablePlugin not implemented yet. No change made to state of plugin' , pluginName ) ;
101
+ logger . warning ( ` enablePlugin() not implemented yet. No change made to state of plugin ${ pluginName } ` ) ;
103
102
}
104
103
105
104
return {
0 commit comments