Skip to content

Commit

Permalink
Make elm a peer dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
0x450x6c committed Apr 3, 2021
1 parent 5c21685 commit 124455b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ test_script:
- node --version
- npm --version
- npm install
- npm install elm elm-test
- npm link
- npm run test
4 changes: 3 additions & 1 deletion bin/create-elm-app-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const path = require('path');
const spawn = require('cross-spawn');
const argv = require('minimist')(process.argv.slice(2));
const version = require('../package.json').version;
const elmVersion = require('elm/package.json').version;
const which = require('which');
const elmExecutable = which.sync('elm', {nothrow: true}) || require.resolve('elm/bin/elm');
const elmVersion = spawn.sync(elmExecutable, ['--version']).stdout.toString().trim();
const commands = argv._;

if (commands.length === 0) {
Expand Down
10 changes: 6 additions & 4 deletions bin/elm-app-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
const path = require('path');
const spawn = require('cross-spawn');
const argv = require('minimist')(process.argv.slice(2));
const elmExecutable = require.resolve('elm/bin/elm');
const which = require('which');
const elmExecutable = which.sync('elm', {nothrow: true}) || require.resolve('elm/bin/elm');
const elmTestExecutable = which.sync('elm-test', {nothrow: true}) || require.resolve('elm-test/bin/elm-test');
const version = require('../package.json').version;
const elmVersion = require('elm/package.json').version;
const elmVersion = spawn.sync(elmExecutable, ['--version']).stdout.toString().trim();

const commands = argv._;

Expand Down Expand Up @@ -66,8 +68,8 @@ switch (script) {
}
});

args = args.concat(['--compiler', require.resolve('elm/bin/elm')]);
const cp = spawn.sync(require.resolve('elm-test/bin/elm-test'), args, {
args = args.concat(['--compiler', elmExecutable]);
const cp = spawn.sync(elmTestExecutable, args, {
stdio: 'inherit'
});

Expand Down
3 changes: 2 additions & 1 deletion config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path');
const fs = require('fs');
const url = require('url');
const cosmiconfig = require('cosmiconfig');
const which = require('which');

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
Expand Down Expand Up @@ -76,7 +77,7 @@ module.exports = {
entry: resolveApp('./src/index.js'),
appBuild: resolveApp('./build'),
elmJson: resolveApp('./elm.json'),
elm: require.resolve('elm/bin/elm'),
elm: which.sync('elm', {nothrow: true}) || require.resolve('elm/bin/elm'),
publicUrl: getPublicUrl(config),
servedPath: getServedPath(config),
proxy: config.proxy,
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@
"cross-spawn": "7.0.3",
"css-loader": "4.3.0",
"dotenv": "8.2.0",
"elm": "latest-0.19.1",
"elm-asset-webpack-loader": "1.1.2",
"elm-hot-webpack-loader": "1.1.7",
"elm-test": "latest-0.19.1",
"elm-webpack-loader": "6.0.1",
"file-loader": "6.2.0",
"fs-extra": "6.0.1",
Expand All @@ -65,6 +63,7 @@
"webpack-dev-server": "3.11.0",
"webpack-manifest-plugin": "2.2.0",
"whatwg-fetch": "3.5.0",
"which": "^2.0.2",
"workbox-webpack-plugin": "4.3.1"
},
"devDependencies": {
Expand All @@ -87,6 +86,10 @@
"shelljs": "0.8.3",
"unexpected": "12.0.0"
},
"peerDependencies": {
"elm": "^0.19.1",
"elm-test": "^0.19.1"
},
"engines": {
"node": ">=8.0.0"
},
Expand Down
3 changes: 2 additions & 1 deletion scripts/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const chalk = require('chalk');
const spawn = require('cross-spawn');
const argv = require('minimist')(process.argv.slice(2));
const commands = argv._;
const elmExecutable = which.sync('elm', {nothrow: true}) || require.resolve('elm/bin/elm');

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

Expand Down Expand Up @@ -44,7 +45,7 @@ function createElmApp(name) {

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

0 comments on commit 124455b

Please sign in to comment.