-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from joncloud/support-linux
Adds support for running makensis on Linux/macOS
- Loading branch information
Showing
10 changed files
with
141 additions
and
36 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
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,81 @@ | ||
const fs = require('fs'); | ||
const { execSync } = require('child_process'); | ||
const path = require('path'); | ||
const { platform, env } = require('process'); | ||
|
||
const firstValidPath = (paths) => { | ||
const possiblePaths = paths.filter(fs.existsSync); | ||
|
||
return possiblePaths.length ? possiblePaths[0] : ''; | ||
}; | ||
|
||
const getWin32Path = () => { | ||
const evaluationPaths = env.PATH.split(';').concat([ | ||
path.join('C:', 'Program Files (x86)', 'NSIS') | ||
]).map(p => path.join(p, 'makensis.exe')); | ||
|
||
return firstValidPath( | ||
evaluationPaths | ||
); | ||
}; | ||
|
||
const getLinuxPath = () => { | ||
const evaluationPaths = env.PATH.split(':').concat([ | ||
'/usr/local/bin', | ||
'/usr/bin', | ||
'/opt/local/bin' | ||
]).map(p => path.join(p, 'makensis')); | ||
|
||
return firstValidPath(evaluationPaths); | ||
}; | ||
|
||
class Makensis { | ||
constructor(path) { | ||
if (!fs.existsSync(path)) { | ||
throw new Error('Unable to find makensis executable'); | ||
} | ||
this.path = path; | ||
} | ||
|
||
execSync(args) { | ||
const buffer = execSync(`"${this.path}" ${args}`); | ||
|
||
return buffer; | ||
} | ||
|
||
getSymbols() { | ||
const buffer = this.execSync('-HDRINFO'); | ||
|
||
// Look for the defined symbols in the output. | ||
const exp = /Defined symbols: (.*)/g; | ||
const matches = exp.exec(buffer.toString('utf-8')); | ||
if (!matches || !matches.length || matches.length < 2) { | ||
throw new Error('Unable to get symbols'); | ||
} | ||
|
||
// Create a map of all of the symbols. | ||
const symbols = { }; | ||
|
||
// Get all of the symbols, which are comma delimited | ||
// keys or key value pairs separated by =. | ||
matches[1].split(',').forEach(text => { | ||
const index = text.indexOf('='); | ||
if (index === -1) { | ||
symbols[text] = ''; | ||
} | ||
else { | ||
const name = text.substr(0, index); | ||
const value = text.substr(index + 1); | ||
symbols[name] = value; | ||
} | ||
}); | ||
|
||
return symbols; | ||
} | ||
} | ||
|
||
const makensisPath = platform === 'win32' | ||
? getWin32Path() | ||
: getLinuxPath(); | ||
|
||
module.exports = new Makensis(makensisPath); |
Empty file.
Empty file.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"mocha": "^8.1.3" | ||
"mocha": "^8.1.3", | ||
"yaml": "^1.10.0" | ||
} | ||
} |
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