mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-13 16:46:26 +00:00
6fb3b92eb8
* Update deps except eslint * Update eslint and lint:fix (WIP, needs manual fixing for remaining 44 problems) * Manually fix remaining eslint errors * Document deprecation of `version-string` as of electron-packager 9.0.0 * Upgrade to Electron 1.7.9 (chrome-58, node-7.9.0, v8-5.8) * npm: Disable generation of package-lock.json and gitignore it --Trying this, package-lock is a pain in PRs. May not be a good idea (obviously we lose deps pinning), will revert if necessary.-- * npm tasks: add dev-up-win for Windows developers, and e2e for end-to-end tests. Update docs. * Move normalizeUrl test to a jest unit test, makes no sense to be in the mocha e2e tests * Switch from babel-preset-es2015 to babel-preset-env, with target.node=4.0. Seem like it's today's most convenient way to support the latest ES and let babel transpile to what makes sense for our currently minimal node version
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
import tmp from 'tmp';
|
|
import chai from 'chai';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import async from 'async';
|
|
|
|
import nativefier from './../../lib/index';
|
|
|
|
const PLATFORMS = ['darwin', 'linux'];
|
|
tmp.setGracefulCleanup();
|
|
const { assert } = chai;
|
|
|
|
function checkApp(appPath, inputOptions, callback) {
|
|
try {
|
|
let relPathToConfig;
|
|
|
|
switch (inputOptions.platform) {
|
|
case 'darwin':
|
|
relPathToConfig = path.join('google-test-app.app', 'Contents/Resources/app');
|
|
break;
|
|
case 'linux':
|
|
relPathToConfig = 'resources/app';
|
|
break;
|
|
case 'win32':
|
|
relPathToConfig = 'resources/app';
|
|
break;
|
|
default:
|
|
throw new Error('Unknown app platform');
|
|
}
|
|
|
|
const nativefierConfigPath = path.join(appPath, relPathToConfig, 'nativefier.json');
|
|
const nativefierConfig = JSON.parse(fs.readFileSync(nativefierConfigPath));
|
|
|
|
assert.strictEqual(inputOptions.targetUrl, nativefierConfig.targetUrl, 'Packaged app must have the same targetUrl as the input parameters');
|
|
// app name is not consistent for linux
|
|
// assert.strictEqual(inputOptions.appName, nativefierConfig.name,
|
|
// 'Packaged app must have the same name as the input parameters');
|
|
callback();
|
|
} catch (exception) {
|
|
callback(exception);
|
|
}
|
|
}
|
|
|
|
describe('Nativefier Module', function testNativefierModule() {
|
|
this.timeout(240000);
|
|
it('Can build an app from a target url', (done) => {
|
|
async.eachSeries(PLATFORMS, (platform, callback) => {
|
|
const tmpObj = tmp.dirSync({ unsafeCleanup: true });
|
|
|
|
const tmpPath = tmpObj.name;
|
|
const options = {
|
|
name: 'google-test-app',
|
|
targetUrl: 'http://google.com',
|
|
out: tmpPath,
|
|
overwrite: true,
|
|
platform: null,
|
|
};
|
|
|
|
options.platform = platform;
|
|
nativefier(options, (error, appPath) => {
|
|
if (error) {
|
|
callback(error);
|
|
return;
|
|
}
|
|
|
|
checkApp(appPath, options, (err) => {
|
|
callback(err);
|
|
});
|
|
});
|
|
}, (error) => {
|
|
done(error);
|
|
});
|
|
});
|
|
});
|
|
|