Skip to content

Commit

Permalink
Merge pull request #395 from tzemanovic/elm-app-create-fix
Browse files Browse the repository at this point in the history
fix(bin/elm-app): pass the correct argument to `elm-app create` command
  • Loading branch information
halfzebra authored Jan 30, 2020
2 parents 42c95f9 + 206e26a commit e430058
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
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);
});
});

0 comments on commit e430058

Please sign in to comment.