Skip to content

Commit

Permalink
Add brew install
Browse files Browse the repository at this point in the history
  • Loading branch information
mfix22 committed Feb 24, 2017
1 parent 1407443 commit 5147b32
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const menubar = require('menubar')

const configure = require('./src/helpers/configure')
const { installImageMagick } = require('./src/api')

const mb = menubar({
alwaysOnTop: true,
Expand All @@ -15,4 +16,6 @@ const { app } = mb
mb.on('ready', () => {
console.log('App started in menu bar.')
configure(mb)

installImageMagick().then(console.log).catch(console.log)
})
16 changes: 10 additions & 6 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const execS = require('child_process').exec
const { replaceSpaceCharacters } = require('./helpers/util')

const convert = ({ files, outputPath, name }) => {
// eslint-disable-next-line dot-notation
process.env['PATH'] = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'

return new Promise((resolve, reject) => {
Expand All @@ -26,12 +27,15 @@ const convert = ({ files, outputPath, name }) => {
const installImageMagick = () => {
return new Promise((resolve, reject) => {
execS('which brew', (error) => {
if (error) reject(new Error('Brew is required to run Alchemy. Please visit https://brew.sh/ to install.'))
else {
execS('brew install imagemagick', (error) => {
return error ? reject(error) : resolve(true)
})
}
if (error) return reject(new Error('Brew is required to run Alchemy. Please visit https://brew.sh/ to install.'))
return execS('which convert', (error) => {
if (error) {
return execS('brew install imagemagick', (error) => {
return error ? reject(error) : resolve('ImageMagick is installed.')
})
}
return resolve('ImageMagick already installed.')
})
})
})
}
Expand Down

0 comments on commit 5147b32

Please sign in to comment.