Skip to content

Commit a240b48

Browse files
author
Elbek Azimov
committed
Make elm a peer dependency.
1 parent 5c21685 commit a240b48

File tree

6 files changed

+25
-12
lines changed

6 files changed

+25
-12
lines changed

appveyor.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ skip_commits:
2525
test_script:
2626
- node --version
2727
- npm --version
28-
- npm install
29-
- npm link
30-
- npm run test
28+
- npm config set prefix .npm-prefix
29+
30+
- cmd: set PATH="%cd%\\.npm-prefix\\bin;%PATH%"
31+
- cmd: call npm install
32+
- cmd: call npm link
33+
- cmd: call npm run test

bin/create-elm-app-cli.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const path = require('path');
66
const spawn = require('cross-spawn');
77
const argv = require('minimist')(process.argv.slice(2));
88
const version = require('../package.json').version;
9-
const elmVersion = require('elm/package.json').version;
9+
const which = require('which');
10+
const elmExecutable = which.sync('elm', {nothrow: true}) || require.resolve('elm/bin/elm');
11+
const elmVersion = spawn.sync(elmExecutable, ['--version']).stdout.toString().trim();
1012
const commands = argv._;
1113

1214
if (commands.length === 0) {

bin/elm-app-cli.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
const path = require('path');
66
const spawn = require('cross-spawn');
77
const argv = require('minimist')(process.argv.slice(2));
8-
const elmExecutable = require.resolve('elm/bin/elm');
8+
const which = require('which');
9+
const elmExecutable = which.sync('elm', {nothrow: true}) || require.resolve('elm/bin/elm');
10+
const elmTestExecutable = which.sync('elm-test', {nothrow: true}) || require.resolve('elm-test/bin/elm-test');
911
const version = require('../package.json').version;
10-
const elmVersion = require('elm/package.json').version;
12+
const elmVersion = spawn.sync(elmExecutable, ['--version']).stdout.toString().trim();
1113

1214
const commands = argv._;
1315

@@ -66,8 +68,8 @@ switch (script) {
6668
}
6769
});
6870

69-
args = args.concat(['--compiler', require.resolve('elm/bin/elm')]);
70-
const cp = spawn.sync(require.resolve('elm-test/bin/elm-test'), args, {
71+
args = args.concat(['--compiler', elmExecutable]);
72+
const cp = spawn.sync(elmTestExecutable, args, {
7173
stdio: 'inherit'
7274
});
7375

config/paths.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const path = require('path');
44
const fs = require('fs');
55
const url = require('url');
66
const cosmiconfig = require('cosmiconfig');
7+
const which = require('which');
78

89
// Make sure any symlinks in the project folder are resolved:
910
// https://github.com/facebookincubator/create-react-app/issues/637
@@ -76,7 +77,7 @@ module.exports = {
7677
entry: resolveApp('./src/index.js'),
7778
appBuild: resolveApp('./build'),
7879
elmJson: resolveApp('./elm.json'),
79-
elm: require.resolve('elm/bin/elm'),
80+
elm: which.sync('elm', {nothrow: true}) || require.resolve('elm/bin/elm'),
8081
publicUrl: getPublicUrl(config),
8182
servedPath: getServedPath(config),
8283
proxy: config.proxy,

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@
3535
"cross-spawn": "7.0.3",
3636
"css-loader": "4.3.0",
3737
"dotenv": "8.2.0",
38-
"elm": "latest-0.19.1",
3938
"elm-asset-webpack-loader": "1.1.2",
4039
"elm-hot-webpack-loader": "1.1.7",
41-
"elm-test": "latest-0.19.1",
4240
"elm-webpack-loader": "6.0.1",
4341
"file-loader": "6.2.0",
4442
"fs-extra": "6.0.1",
@@ -65,6 +63,7 @@
6563
"webpack-dev-server": "3.11.0",
6664
"webpack-manifest-plugin": "2.2.0",
6765
"whatwg-fetch": "3.5.0",
66+
"which": "^2.0.2",
6867
"workbox-webpack-plugin": "4.3.1"
6968
},
7069
"devDependencies": {
@@ -87,6 +86,10 @@
8786
"shelljs": "0.8.3",
8887
"unexpected": "12.0.0"
8988
},
89+
"peerDependencies": {
90+
"elm": "latest-0.19.1",
91+
"elm-test": "latest-0.19.1"
92+
},
9093
"engines": {
9194
"node": ">=8.0.0"
9295
},

scripts/create.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const chalk = require('chalk');
77
const spawn = require('cross-spawn');
88
const argv = require('minimist')(process.argv.slice(2));
99
const commands = argv._;
10+
const which = require('which');
11+
const elmExecutable = which.sync('elm', {nothrow: true}) || require.resolve('elm/bin/elm');
1012

1113
const isWindows = process.platform === 'win32';
1214

@@ -44,7 +46,7 @@ function createElmApp(name) {
4446

4547
// Run initial `elm make`
4648
const spawnElmPkgResult = spawn.sync(
47-
path.resolve(__dirname, '../node_modules/.bin/elm'),
49+
elmExecutable,
4850
// Run elm-make to install the dependencies.
4951
['make', 'src/Main.elm', '--output=/dev/null'],
5052
{ stdio: 'inherit', cwd: appRoot }

0 commit comments

Comments
 (0)