Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bin/elm-app-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ if (commands.length === 0) {
const script = commands[0];

switch (script) {
case 'create':
case 'build':
case 'eject':
case 'start':
Expand All @@ -55,6 +54,10 @@ switch (script) {
spawnSyncNode(path.resolve(__dirname, '../scripts', script), args, env);
break;

case 'create':
spawnSyncNode(path.resolve(__dirname, '../scripts/create'), commands[1]);
break;

case 'test': {
let args = [];
Object.keys(argv || {}).forEach(key => {
Expand Down
39 changes: 39 additions & 0 deletions tests/elm-app.create.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const path = require('path');
const expect = require('unexpected');
const spawn = require('cross-spawn');
const dircompare = require('dir-compare');
const fs = require('fs');
const rimraf = require('rimraf');

const testAppName = 'test-app-eject';
const rootDir = path.resolve(__dirname, '..');
const testAppDir = path.join(rootDir, testAppName);
const elmAppCmd = path.join(rootDir, 'bin/elm-app-cli.js');

describe('Create Elm application with `elm-app create` command', () => {
after(() => {
rimraf.sync(testAppDir);
});

it(`'elm-app create ${testAppName}' should succeed`, () => {
const { status } = spawn.sync('node', [elmAppCmd, 'create', testAppName]);
expect(status, 'to be', 0);
}).timeout(60 * 1000);

it(`'${testAppName}' should have elm.json file`, () => {
expect(fs.existsSync(path.join(testAppDir, 'elm.json')), 'to be', true);
});

it(`'${testAppName}' should have .gitignore file`, () => {
expect(fs.existsSync(path.join(testAppDir, '.gitignore')), 'to be', true);
});

it(`'${testAppName}' should have the same file structure as template`, () => {
const templateDir = path.join(rootDir, 'template');
const options = {
excludeFilter: 'elm-stuff, elm.json, gitignore, .gitignore, build'
};
const { same } = dircompare.compareSync(templateDir, testAppDir, options);
expect(same, 'to be', true);
});
});