File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,29 @@ async function getElmVersion(elmBinary) {
63
63
return trimVersion ( result . stdout . toString ( ) ) ;
64
64
}
65
65
66
+ /** Download the dependencies of the project to analyze.
67
+ *
68
+ * @param {Path } elmBinary
69
+ * @param {Path } elmJsonPath
70
+ * @return {Promise<void> }
71
+ */
72
+ async function downloadDependenciesOfElmJson ( elmBinary , elmJsonPath ) {
73
+ const result = spawn . sync ( elmBinary , [ 'make' , '--report=json' ] , {
74
+ cwd : path . dirname ( elmJsonPath ) ,
75
+ silent : false ,
76
+ env : process . env
77
+ } ) ;
78
+
79
+ if ( result . status !== 0 ) {
80
+ const error = JSON . parse ( result . stderr . toString ( ) ) ;
81
+ // TODO Check for other kinds of errors
82
+ if ( error . title !== 'NO INPUT' ) {
83
+ // TODO Print error nicely
84
+ throw new Error ( error ) ;
85
+ }
86
+ }
87
+ }
88
+
66
89
/**
67
90
* @param {string } version
68
91
* @return {string }
@@ -78,5 +101,6 @@ function trimVersion(version) {
78
101
79
102
module . exports = {
80
103
getElmBinary,
81
- getElmVersion
104
+ getElmVersion,
105
+ downloadDependenciesOfElmJson
82
106
} ;
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ const NewRule = require('./new-rule');
17
17
const Anonymize = require ( './anonymize' ) ;
18
18
const newPackage = require ( './new-package' ) ;
19
19
const AppWrapper = require ( './app-wrapper' ) ;
20
+ const ElmFiles = require ( './elm-files' ) ;
21
+ const ElmBinary = require ( './elm-binary' ) ;
20
22
const ResultCache = require ( './result-cache' ) ;
21
23
const ErrorMessage = require ( './error-message' ) ;
22
24
const SuppressedErrors = require ( './suppressed-errors' ) ;
@@ -107,7 +109,10 @@ async function runElmReviewInWatchMode() {
107
109
}
108
110
109
111
async function prepareOffline ( ) {
110
- const { elmModulePath, reviewElmJson, appHash} = await Builder . build ( options ) ;
112
+ const elmBinary = await ElmBinary . getElmBinary ( options ) ;
113
+ await ElmBinary . downloadDependenciesOfElmJson ( elmBinary , options . elmJsonPath ) ;
114
+
115
+ const { elmModulePath, reviewElmJson} = await Builder . build ( options ) ;
111
116
112
117
if ( ! elmModulePath ) {
113
118
AppState . exitRequested ( 1 ) ;
You can’t perform that action at this time.
0 commit comments