Skip to content
Permalink
Browse files

fix(starter): throw an error if the app version is not set in package…

….json

ISSUES CLOSED: #351
  • Loading branch information
malept committed Oct 22, 2017
1 parent b3499ed commit 69b29958a1c45c422bd213ca1f8cde306306ed6d
Showing with 20 additions and 1 deletion.
  1. +4 −0 src/api/start.js
  2. +16 −1 test/fast/start_spec.js
@@ -46,6 +46,10 @@ export default async (providedOptions = {}) => {

const packageJSON = await readPackageJSON(dir);

if (!packageJSON.version) {
throw `Please set your application's 'version' in '${dir}/package.json'.`;
}

await rebuild(dir, packageJSON.devDependencies['electron-prebuilt-compile'], process.platform, process.arch);

const spawnOpts = {
@@ -8,16 +8,19 @@ chai.use(chaiAsPromised);

describe('start', () => {
let start;
let packageJSON;
let resolveStub;
let spawnStub;

beforeEach(() => {
resolveStub = sinon.stub();
spawnStub = sinon.stub();
packageJSON = require('../fixture/dummy_app/package.json');

start = proxyquire.noCallThru().load('../../src/api/start', {
'../util/forge-config': async () => ({}),
'../util/resolve-dir': async dir => resolveStub(dir),
'../util/read-package-json': () => Promise.resolve(require('../fixture/dummy_app/package.json')),
'../util/read-package-json': () => Promise.resolve(packageJSON),
'../util/rebuild': () => Promise.resolve(),
child_process: {
spawn: spawnStub,
@@ -104,6 +107,18 @@ describe('start', () => {
);
});

it('should throw if no version is in package.json', async () => {
resolveStub.returnsArg(0);
packageJSON = Object.assign({}, packageJSON);
delete packageJSON.version;
await expect(start({
dir: __dirname,
interactive: false,
})).to.eventually.be.rejectedWith(
`Please set your application's 'version' in '${__dirname}/package.json'.`
);
});

it('should pass all args through to the spawned Electron instance', async () => {
const args = ['magic_arg', 123, 'thingy'];
resolveStub.returnsArg(0);

0 comments on commit 69b2995

Please sign in to comment.
You can’t perform that action at this time.