ember-chromium
Advanced tools
Comparing version 4.0.0 to 4.0.2
@@ -94,15 +94,14 @@ #!/usr/bin/env node | ||
module.exports = (function () { | ||
return utils.getBinaryPath().then(({execPath, binPath, versionNumber }) => { | ||
const exists = fs.existsSync(execPath); | ||
const { execPath, binPath, versionNumber } = utils.getBinaryPath(); | ||
const exists = fs.existsSync(execPath); | ||
if (exists) { | ||
console.log('Chrome is already installed'); | ||
} else { | ||
console.log('Chrome is not installed, triggering download'); | ||
return utils.getChromiumBranchingPoint(versionNumber) | ||
.then(downloadChromiumRevision) | ||
.then(path => unzipArchive(path, binPath)) | ||
.catch(err => console.error('An error occurred while trying to setup Chromium. Resolve all issues and restart the process', err)); | ||
} | ||
}); | ||
if (exists) { | ||
console.log('Chrome is already installed'); | ||
} else { | ||
console.log('Chrome is not installed, triggering download'); | ||
return utils.getChromiumBranchingPoint(versionNumber) | ||
.then(downloadChromiumRevision) | ||
.then(path => unzipArchive(path, binPath)) | ||
.catch(err => console.error('An error occurred while trying to setup Chromium. Resolve all issues and restart the process', err)); | ||
} | ||
})(); |
47
index.js
@@ -20,29 +20,28 @@ /* global require, module */ | ||
return utils.getBinaryPath().then(({execPath}) => { | ||
if (!fs.existsSync(execPath)) { | ||
console.error('Chromium does not appear to be installed, testem cannot run.'); // eslint-disable-line | ||
process.exit(1); // for some reason this doesn't stop testem from continuing in server mode | ||
throw new Error('Chromium not installed'); | ||
} | ||
const { execPath } = utils.getBinaryPath(); | ||
if (!fs.existsSync(execPath)) { | ||
console.error('Chromium does not appear to be installed, testem cannot run.'); // eslint-disable-line | ||
process.exit(1); // for some reason this doesn't stop testem from continuing in server mode | ||
throw new Error('Chromium not installed'); | ||
} | ||
return { | ||
test_page: 'tests/index.html?hidepassed', | ||
browser_start_timeout: 60, | ||
launchers: { | ||
chromium: { | ||
exe: execPath, | ||
args: chromiumArgs, | ||
protocol: 'browser' | ||
}, | ||
chromium_headless: { | ||
exe: execPath, | ||
args: ['--headless', ...chromiumArgs], | ||
protocol: 'browser' | ||
} | ||
return { | ||
test_page: 'tests/index.html?hidepassed', | ||
browser_start_timeout: 60, | ||
launchers: { | ||
chromium: { | ||
exe: execPath, | ||
args: chromiumArgs, | ||
protocol: 'browser' | ||
}, | ||
chromium_headless: { | ||
exe: execPath, | ||
args: ['--headless', ...chromiumArgs], | ||
protocol: 'browser' | ||
} | ||
}, | ||
launch_in_ci: ['chromium_headless'], | ||
launch_in_dev: ['chromium'] | ||
}; | ||
}); | ||
launch_in_ci: ['chromium_headless'], | ||
launch_in_dev: ['chromium'] | ||
}; | ||
} | ||
@@ -49,0 +48,0 @@ |
{ | ||
"name": "ember-chromium", | ||
"version": "4.0.0", | ||
"version": "4.0.2", | ||
"description": "One place to hold all the logic to download and run ember tests in chromium", | ||
@@ -9,3 +9,5 @@ "main": "index.js", | ||
}, | ||
"publishConfig": { "registry": "https://registry.npmjs.org" }, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
"scripts": { | ||
@@ -12,0 +14,0 @@ "postinstall": "node download-chrome.js", |
53
utils.js
@@ -63,28 +63,34 @@ #!/usr/bin/env node | ||
function getBinaryPath () { | ||
return getExactChromeVersionNumber() | ||
.then(versionNumber => { | ||
const buffer = childProcess.execSync('npm bin -g'); | ||
const result = String.fromCharCode.apply(null, buffer); | ||
const globalPath = result.replace(/\n$/, ''); | ||
let binPath = path.join(globalPath, 'ember-chromium', versionNumber); | ||
let execPath; | ||
// run async function synchronously because testem doesn't like async configs | ||
// I'm not proud of this but it works. | ||
const versionBuffer = childProcess.execSync(` | ||
node -e " | ||
require('ember-chromium/utils').getExactChromeVersionNumber() | ||
.then(v => process.stdout.write(v)) | ||
" | ||
`); | ||
const versionNumber = String.fromCharCode.apply(null, versionBuffer); | ||
const buffer = childProcess.execSync('npm bin -g'); | ||
const result = String.fromCharCode.apply(null, buffer); | ||
const globalPath = result.replace(/\n$/, ''); | ||
let binPath = path.join(globalPath, 'ember-chromium', versionNumber); | ||
let execPath; | ||
const platform = process.platform; | ||
const folderName = getOsChromiumFolderName(); | ||
const platform = process.platform; | ||
const folderName = getOsChromiumFolderName(); | ||
if (platform === 'linux') { | ||
execPath = path.join(binPath, folderName, 'chrome'); | ||
} else if (platform === 'win32') { | ||
execPath = path.join(binPath, folderName, 'chrome.exe'); | ||
} else if (platform === 'darwin') { | ||
execPath = path.join(binPath, folderName, 'Chromium.app/Contents/MacOS/Chromium'); | ||
} else { | ||
console.error('Unsupported platform or architecture found:', process.platform, process.arch); | ||
throw new Error('Unsupported platform'); | ||
} | ||
if (platform === 'linux') { | ||
execPath = path.join(binPath, folderName, 'chrome'); | ||
} else if (platform === 'win32') { | ||
execPath = path.join(binPath, folderName, 'chrome.exe'); | ||
} else if (platform === 'darwin') { | ||
execPath = path.join(binPath, folderName, 'Chromium.app/Contents/MacOS/Chromium'); | ||
} else { | ||
console.error('Unsupported platform or architecture found:', process.platform, process.arch); | ||
throw new Error('Unsupported platform'); | ||
} | ||
console.log(`checking for chromium at: ${execPath.toString()}`); | ||
console.log(`checking for chromium at: ${execPath.toString()}`); | ||
return {binPath, execPath, versionNumber}; | ||
}); | ||
return {binPath, execPath, versionNumber}; | ||
} | ||
@@ -134,3 +140,4 @@ | ||
getOsChromiumFolderName, | ||
getChromiumBranchingPoint | ||
getChromiumBranchingPoint, | ||
getExactChromeVersionNumber | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11519
270
2