Merge pull request #6634 from Toilal/feature/yarn-custom-build-fix

Fix custom build when openlayers is installed from yarn package manager
This commit is contained in:
Andreas Hocevar
2017-03-26 22:43:21 +02:00
committed by GitHub
+25 -5
View File
@@ -14,14 +14,34 @@ var externsPaths = [
]; ];
var infoPath = path.join(__dirname, '..', 'build', 'info.json'); var infoPath = path.join(__dirname, '..', 'build', 'info.json');
var jsdocResolved = require.resolve('jsdoc/jsdoc.js'); /**
var jsdoc = path.resolve(path.dirname(jsdocResolved), '../.bin/jsdoc'); * Get checked path of a binary.
* @param {string} binaryName Binary name of the binary path to find.
* @return {string} Path.
*/
function getBinaryPath(binaryName) {
if (isWindows) {
binaryName += '.cmd';
}
// on Windows, use jsdoc.cmd var jsdocResolved = require.resolve('jsdoc/jsdoc.js');
if (isWindows) { var expectedPaths = [
jsdoc += '.cmd'; path.join(__dirname, '..', 'node_modules', '.bin', binaryName),
path.resolve(path.join(path.dirname(jsdocResolved), '..', '.bin', binaryName))
];
for (var i = 0; i < expectedPaths.length; i++) {
var expectedPath = expectedPaths[i];
if (fs.existsSync(expectedPath)) {
return expectedPath;
}
}
throw Error('JsDoc binary was not found in any of the expected paths: ' + expectedPaths);
} }
var jsdoc = getBinaryPath('jsdoc');
var jsdocConfig = path.join( var jsdocConfig = path.join(
__dirname, '..', 'config', 'jsdoc', 'info', 'conf.json'); __dirname, '..', 'config', 'jsdoc', 'info', 'conf.json');