Skip to content

Commit fdcfa3b

Browse files
authored
Merge pull request #168 from halfzebra/add-package-install-alias
Add package install alias
2 parents 77eb2c8 + 9206387 commit fdcfa3b

File tree

5 files changed

+53
-35
lines changed

5 files changed

+53
-35
lines changed

bin/elm-app-cli.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ switch (script) {
5050

5151
break;
5252
}
53+
case 'install': {
54+
const executable = executablePaths['elm-package'];
55+
spawn.sync(path.normalize(executable), process.argv.slice(2), {
56+
stdio: 'inherit'
57+
});
58+
break;
59+
}
5360
default:
5461
// Proxy elm-platform cli commands.
5562
if (['package', 'reactor', 'make', 'repl'].indexOf(script) !== -1) {
@@ -74,7 +81,9 @@ switch (script) {
7481
function help(version) {
7582
console.log('\nUsage: elm-app <command>\n');
7683
console.log('where <command> is one of:');
77-
console.log(' create, build, start, package, reactor, make, repl\n');
84+
console.log(
85+
' create, build, start, install, package, reactor, make, repl\n'
86+
);
7887
console.log('\nElm ' + elmPlatformVersion + '\n');
7988
console.log(
8089
'create-elm-app@' + version + ' ' + path.resolve(__dirname, '..')

scripts/utils/webpackHotDevClient.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ var connection = new SockJS(
159159
hostname: window.location.hostname,
160160
port: window.location.port,
161161
// Hardcoded in WebpackDevServer
162-
pathname: '/sockjs-node',
162+
pathname: '/sockjs-node'
163163
})
164164
);
165165

@@ -218,7 +218,7 @@ function handleWarnings(warnings) {
218218
// Print warnings to the console.
219219
var formatted = formatWebpackMessages({
220220
warnings: warnings,
221-
errors: [],
221+
errors: []
222222
});
223223

224224
if (typeof console !== 'undefined' && typeof console.warn === 'function') {
@@ -259,10 +259,12 @@ function handleErrors(errors) {
259259
hasCompileErrors = true;
260260

261261
// "Massage" webpack messages.
262-
var formatted = highlightElmCompilerErrors(formatWebpackMessages({
263-
errors: errors,
264-
warnings: [],
265-
}));
262+
var formatted = highlightElmCompilerErrors(
263+
formatWebpackMessages({
264+
errors: errors,
265+
warnings: []
266+
})
267+
);
266268

267269
// Only show the first error.
268270
showErrorOverlay(formatted.errors[0]);

template/README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ You can find the most recent version of this guide [here](https://github.com/hal
1111
- [Available scripts](#available-scripts)
1212
- [elm-app build](#elm-app-build)
1313
- [elm-app start](#elm-app-start)
14+
- [elm-app install](#elm-app-install)
1415
- [elm-app test](#elm-app-test)
1516
- [elm-app eject](#elm-app-eject)
1617
- [elm-app <elm-platform-comand>](#elm-app-elm-platform-comand)
@@ -41,9 +42,11 @@ You are very welcome with any [feedback](https://github.com/halfzebra/create-elm
4142
## Installing Elm packages
4243

4344
```sh
44-
elm-app package install <package-name>
45+
elm-app install <package-name>
4546
```
4647

48+
Other `elm-package` commands are also [available.](#package)
49+
4750
## Installing JavaScript packages
4851

4952
To use JavaScript packages from npm, you'll need to add a `package.json`, install the dependencies, and you're ready to go.
@@ -102,6 +105,10 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
102105
The page will reload if you make edits.
103106
You will also see any lint errors in the console.
104107

108+
### `elm-app install`
109+
110+
An alias for [`elm-app package install`](#package)
111+
105112
### `elm-app test`
106113
Run tests with [node-test-runner](https://github.com/rtfeldman/node-test-runner/tree/master)
107114

@@ -111,6 +118,7 @@ elm-app test --watch
111118
```
112119

113120
### `elm-app eject`
121+
114122
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
115123

116124
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time.
@@ -120,20 +128,25 @@ Instead, it will copy all the configuration files and the transitive dependencie
120128
You don’t have to use 'eject' The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However, we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
121129

122130
### `elm-app <elm-platform-comand>`
131+
123132
Create Elm App does not rely on the global installation of Elm Platform, but you still can use it's local Elm Platform to access default command line tools:
124133

125134
#### `package`
135+
126136
Alias for [elm-package](http://guide.elm-lang.org/get_started.html#elm-package)
127137

128138
Use it for installing Elm packages from [package.elm-lang.org](http://package.elm-lang.org/)
129139

130140
#### `repl`
141+
131142
Alias for [elm-repl](http://guide.elm-lang.org/get_started.html#elm-repl)
132143

133144
#### `make`
145+
134146
Alias for [elm-make](http://guide.elm-lang.org/get_started.html#elm-make)
135147

136148
#### `reactor`
149+
137150
Alias for [elm-reactor](http://guide.elm-lang.org/get_started.html#elm-reactor)
138151

139152

tests/elm-app.build.spec.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,21 @@ describe('Building Elm application with `elm-app build`', function() {
4040
expect(fs.existsSync(path.join(testAppDir, 'build'))).to.be.equal(true);
4141
}).timeout(12 * 60 * 1000);
4242

43-
it(
44-
'`elm-app build` should exit with non zero status code when build failed',
45-
function() {
46-
const normalFile = path.join(testAppDir, 'src/Main.elm');
47-
const malformedFile = path.join(rootDir, './tests/fixtures/Main.elm');
43+
it('`elm-app build` should exit with non zero status code when build failed', function() {
44+
const normalFile = path.join(testAppDir, 'src/Main.elm');
45+
const malformedFile = path.join(rootDir, './tests/fixtures/Main.elm');
4846

49-
copyFileSync(normalFile, 'Main.elm-normal');
50-
copyFileSync(malformedFile, normalFile);
47+
copyFileSync(normalFile, 'Main.elm-normal');
48+
copyFileSync(malformedFile, normalFile);
5149

52-
const result = spawn.sync('node', [elmAppCmd, 'build']);
50+
const result = spawn.sync('node', [elmAppCmd, 'build']);
5351

54-
const oldNormalFile = path.resolve('Main.elm-normal');
55-
copyFileSync(oldNormalFile, normalFile);
56-
fs.unlink(oldNormalFile);
52+
const oldNormalFile = path.resolve('Main.elm-normal');
53+
copyFileSync(oldNormalFile, normalFile);
54+
fs.unlink(oldNormalFile);
5755

58-
expect(result.status).to.be.at.least(1);
59-
}
60-
).timeout(2 * 60 * 1000);
56+
expect(result.status).to.be.at.least(1);
57+
}).timeout(2 * 60 * 1000);
6158
});
6259

6360
function copyFileSync(from, to) {

tests/elm-app.eject.spec.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,15 @@ describe('Ejecting Elm application. (Please wait...)', () => {
7070
expect(same).to.be.equal(true);
7171
});
7272

73-
it(
74-
'It should be possible to build ejected applitaction, using npm scripts',
75-
() => {
76-
const result = spawn.sync('npm', ['run', 'build']);
77-
const outputString = result.output
78-
.map(function(out) {
79-
return out !== null ? out.toString() : '';
80-
})
81-
.join('');
73+
it('It should be possible to build ejected applitaction, using npm scripts', () => {
74+
const result = spawn.sync('npm', ['run', 'build']);
75+
const outputString = result.output
76+
.map(function(out) {
77+
return out !== null ? out.toString() : '';
78+
})
79+
.join('');
8280

83-
expect(result.status).to.be.equal(0);
84-
expect(outputString).to.have.string('Compiled successfully');
85-
}
86-
).timeout(5 * 60 * 1000);
81+
expect(result.status).to.be.equal(0);
82+
expect(outputString).to.have.string('Compiled successfully');
83+
}).timeout(5 * 60 * 1000);
8784
});

0 commit comments

Comments
 (0)