@@ -63,7 +63,7 @@ class MinimapPluginGeneratorElement {
6363 setPathText ( placeholderName , rangeToSelect ) {
6464 if ( ! rangeToSelect ) { rangeToSelect = [ 0 , placeholderName . length ] }
6565
66- const packagesDirectory = this . getPackagesDirectory ( )
66+ const packagesDirectory = getPackagesDirectory ( )
6767
6868 this . editor . setText ( path . join ( packagesDirectory , placeholderName ) )
6969
@@ -112,12 +112,6 @@ class MinimapPluginGeneratorElement {
112112 return path . join ( path . dirname ( packagePath ) , packageName )
113113 }
114114
115- getPackagesDirectory ( ) {
116- return atom . config . get ( 'core.projectHome' ) ||
117- process . env . ATOM_REPOS_HOME ||
118- path . join ( getHomeDirectory ( ) , 'github' )
119- }
120-
121115 validPackagePath ( ) {
122116 if ( existsSync ( this . getPackagePath ( ) ) ) {
123117 this . error . textContent = `Path already exists at '${ this . getPackagePath ( ) } '`
@@ -130,52 +124,58 @@ class MinimapPluginGeneratorElement {
130124
131125 initPackage ( packagePath , callback ) {
132126 const templatePath = path . resolve ( __dirname , path . join ( '..' , 'templates' , `plugin-${ this . template } ` ) )
133- this . runCommand ( atom . packages . getApmPath ( ) , [ 'init' , '-p' , `${ packagePath } ` , '--template' , templatePath ] , callback )
134- }
135-
136- linkPackage ( packagePath , callback ) {
137- const args = [ 'link' ]
138- if ( atom . config . get ( 'minimap.createPluginInDevMode' ) ) { args . push ( '--dev' ) }
139- args . push ( packagePath . toString ( ) )
140-
141- this . runCommand ( atom . packages . getApmPath ( ) , args , callback )
142- }
143-
144- installPackage ( packagePath , callback ) {
145- const args = [ 'install' ]
146-
147- this . runCommand ( atom . packages . getApmPath ( ) , args , callback , { cwd : packagePath } )
148- }
149-
150- isStoredInDotAtom ( packagePath ) {
151- const packagesPath = path . join ( atom . getConfigDirPath ( ) , 'packages' , path . sep )
152- if ( packagePath . indexOf ( packagesPath ) === 0 ) { return true }
153-
154- const devPackagesPath = path . join ( atom . getConfigDirPath ( ) , 'dev' , 'packages' , path . sep )
155-
156- return packagePath . indexOf ( devPackagesPath ) === 0
127+ runCommand ( atom . packages . getApmPath ( ) , [ 'init' , '-p' , `${ packagePath } ` , '--template' , templatePath ] , callback )
157128 }
158129
159130 createPackageFiles ( callback ) {
160131 const packagePath = this . getPackagePath ( )
161132
162- if ( this . isStoredInDotAtom ( packagePath ) ) {
133+ if ( isStoredInDotAtom ( packagePath ) ) {
163134 this . initPackage ( packagePath , ( ) => {
164- this . installPackage ( packagePath , callback )
135+ installPackage ( packagePath , callback )
165136 } )
166137 } else {
167138 this . initPackage ( packagePath , ( ) => {
168- this . linkPackage ( packagePath , ( ) => {
169- this . installPackage ( packagePath , callback )
139+ linkPackage ( packagePath , ( ) => {
140+ installPackage ( packagePath , callback )
170141 } )
171142 } )
172143 }
173144 }
174-
175- runCommand ( command , args , exit , options = { } ) {
176- return new BufferedProcess ( { command, args, exit, options } )
177- }
178145}
179146
180147const minimapPluginGeneratorElement = MinimapPluginGeneratorElement . initClass ( )
181148export default minimapPluginGeneratorElement
149+
150+ function linkPackage ( packagePath , callback ) {
151+ const args = [ 'link' ]
152+ if ( atom . config . get ( 'minimap.createPluginInDevMode' ) ) { args . push ( '--dev' ) }
153+ args . push ( packagePath . toString ( ) )
154+
155+ runCommand ( atom . packages . getApmPath ( ) , args , callback )
156+ }
157+
158+ function installPackage ( packagePath , callback ) {
159+ const args = [ 'install' ]
160+
161+ runCommand ( atom . packages . getApmPath ( ) , args , callback , { cwd : packagePath } )
162+ }
163+
164+ function getPackagesDirectory ( ) {
165+ return atom . config . get ( 'core.projectHome' ) ||
166+ process . env . ATOM_REPOS_HOME ||
167+ path . join ( getHomeDirectory ( ) , 'github' )
168+ }
169+
170+ function isStoredInDotAtom ( packagePath ) {
171+ const packagesPath = path . join ( atom . getConfigDirPath ( ) , 'packages' , path . sep )
172+ if ( packagePath . indexOf ( packagesPath ) === 0 ) { return true }
173+
174+ const devPackagesPath = path . join ( atom . getConfigDirPath ( ) , 'dev' , 'packages' , path . sep )
175+
176+ return packagePath . indexOf ( devPackagesPath ) === 0
177+ }
178+
179+ function runCommand ( command , args , exit , options = { } ) {
180+ return new BufferedProcess ( { command, args, exit, options } )
181+ }
0 commit comments