-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
831 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
language: node_js | ||
node_js: | ||
- '6' | ||
before_deploy: | ||
- 'npm run build' | ||
- 'npm run package' | ||
- 'npm run zip' | ||
deploy: | ||
provider: releases | ||
api_key: | ||
secure: V+pC1E/0CnhPcXr/BF4S3mVFzEQe7OInc6h8rpw9eXS5GrV2x3ehaUrsZCu+SEU5m8l8R95Lq6b2FScSHIj0NyWfpKf2J/a/TwQnvpOeZ0QDFVe6sUHDv8BGH+aQmyfH6Wd/M+t90gkDrFx0W+skm5t91ohkjJLlUF3afvxw2XpGO12//LS7dfCxffpWZcdV4DHN8AGJ0Kxu7wKBJIzeTIhdcJhmLmHo70PlDF0tJOXb6kFyHmD59vv0RjKBLTH10JQ9uaVjRc9+wuqTGEm6kgLTHfx3TWgSDQxn6bOiTnwdHZkSqeTRzdWilNVeX2fW0gq732L+wOYwx2krmJfl7m7XOi3YDutoVeHiBQt0FwFwsEWBQb3lDK/7xazYvob56wR2BFNIDcTsKIPewgIO0WEi/6Sz+XReBwn3EnPBKT4O6YOownBpMy9vzCVv5i/NQdhQs+qIlTOrpt42KxVOPLZ4VpqFR82PxSV9lmJK0db+d/CxLcT98n1WQsYO86p5enD1O6CvTw2fgG7tm4DPeKuOeTzX93T6BDx74JvrmvPq0phUa+dVJ/uCI4Dv+4gqKb1F22hJ/e7KssDs4XQmDpw7J3IMZySwmOq9hNBMETZrO9hIbuKZjTynw1LHK5Sbj0vh6+A4ZhG5hHIhYM0uNN2eO5kqKIqSzLs9t0gj9gw= | ||
file: ./packaged/Alchemy.zip | ||
skip_cleanup: true | ||
on: | ||
tags: true |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,45 @@ | ||
const { exec, which } = require('shelljs') | ||
const md5 = require('md5') | ||
const execS = require('child_process').exec | ||
const { replaceSpaceCharacters, createOutputFileName } = require('./helpers/util') | ||
|
||
const { replaceSpaceCharacters } = require('./helpers/util') | ||
|
||
const convert = ({ files, outputPath, name }) => { | ||
const convert = ({ files, outputPath, outputType, name }) => { | ||
// eslint-disable-next-line dot-notation | ||
process.env['PATH'] = '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' | ||
|
||
return new Promise((resolve, reject) => { | ||
execS('which convert', (error, stdout, stderr) => { | ||
execS('which convert', (error) => { | ||
if (error) reject(error) | ||
else { | ||
const fileString = files.map(replaceSpaceCharacters).join(' ') | ||
const outputName = name || `ALCHEMY-${md5(fileString).substr(0, 6)}.pdf` | ||
const command = `convert ${fileString} ${outputPath}${outputName}` | ||
console.log(command) | ||
|
||
execS(command, (error) => { | ||
if (error) reject(error) | ||
else resolve(outputName) | ||
}) | ||
} | ||
const outputName = name || createOutputFileName(outputType)(files) | ||
const command = [ | ||
'convert', | ||
...files.map(replaceSpaceCharacters), // input files | ||
outputPath + outputName | ||
].join(' ') | ||
|
||
console.log(command) | ||
|
||
return execS(command, err => (err ? reject(err) : resolve(outputName))) | ||
}) | ||
}) | ||
} | ||
|
||
const checkForBrew = () => !!which('brew') | ||
const checkForImageMagick = () => !!which('convert') | ||
const installImageMagick = () => { | ||
if (!checkForBrew()) return Promise.resolve(-1) | ||
|
||
if (!checkForImageMagick()) { | ||
if (confirm('ImageMagick is required to run this app. Install now?')) { | ||
return new Promise((resolve) => { | ||
exec('brew install imagemagick', (code) => { | ||
resolve(code) | ||
}) | ||
return new Promise((resolve, reject) => { | ||
execS('which brew', (error) => { | ||
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.') | ||
}) | ||
} | ||
} | ||
|
||
return Promise.resolve(0) | ||
}) | ||
}) | ||
} | ||
|
||
module.exports = { | ||
convert, | ||
checkForBrew, | ||
checkForImageMagick, | ||
installImageMagick | ||
} |
Oops, something went wrong.