Skip to content

Commit

Permalink
fix: make linkPackage and installPackage free functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Dec 31, 2020
1 parent b592149 commit 32987c7
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions lib/minimap-plugin-generator-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,17 @@ class MinimapPluginGeneratorElement {
runCommand(atom.packages.getApmPath(), ['init', '-p', `${packagePath}`, '--template', templatePath], callback)
}

linkPackage (packagePath, callback) {
const args = ['link']
if (atom.config.get('minimap.createPluginInDevMode')) { args.push('--dev') }
args.push(packagePath.toString())

runCommand(atom.packages.getApmPath(), args, callback)
}

installPackage (packagePath, callback) {
const args = ['install']

runCommand(atom.packages.getApmPath(), args, callback, { cwd: packagePath })
}

createPackageFiles (callback) {
const packagePath = this.getPackagePath()

if (isStoredInDotAtom(packagePath)) {
this.initPackage(packagePath, () => {
this.installPackage(packagePath, callback)
installPackage(packagePath, callback)
})
} else {
this.initPackage(packagePath, () => {
this.linkPackage(packagePath, () => {
this.installPackage(packagePath, callback)
linkPackage(packagePath, () => {
installPackage(packagePath, callback)
})
})
}
Expand All @@ -161,6 +147,20 @@ class MinimapPluginGeneratorElement {
const minimapPluginGeneratorElement = MinimapPluginGeneratorElement.initClass()
export default minimapPluginGeneratorElement

function linkPackage (packagePath, callback) {
const args = ['link']
if (atom.config.get('minimap.createPluginInDevMode')) { args.push('--dev') }
args.push(packagePath.toString())

runCommand(atom.packages.getApmPath(), args, callback)
}

function installPackage (packagePath, callback) {
const args = ['install']

runCommand(atom.packages.getApmPath(), args, callback, { cwd: packagePath })
}

function getPackagesDirectory () {
return atom.config.get('core.projectHome') ||
process.env.ATOM_REPOS_HOME ||
Expand Down

0 comments on commit 32987c7

Please sign in to comment.