@@ -192,25 +192,27 @@ function init({ typescript: ts }: { typescript: typeof ts_module }) {
192
192
// Manually open .env and parse just the SASS_PATH part,
193
193
// because we don't *need* to apply the full .env to this environment,
194
194
// and we are not sure doing so wouldn't have side effects
195
- const dotenv = fs . readFileSync ( dotenvPath , { encoding : 'utf8' } ) ;
196
- const sassPathMatch = sassPathRegex . exec ( dotenv ) ;
197
-
198
- if ( sassPathMatch && sassPathMatch [ 1 ] ) {
199
- const sassPaths = sassPathMatch [ 1 ] . split ( path . delimiter ) ;
200
-
201
- // Manually convert relative paths in SASS_PATH to absolute,
202
- // lest they be resolved relative to process.cwd which would almost certainly be wrong
203
- for (
204
- var i = 0 , currPath = sassPaths [ i ] ;
205
- i < sassPaths . length ;
206
- currPath = sassPaths [ ++ i ]
207
- ) {
208
- if ( path . isAbsolute ( currPath ) ) continue ;
209
- sassPaths [ i ] = path . resolve ( projectDir , currPath ) ; // resolve path relative to project directory
195
+ try {
196
+ const dotenv = fs . readFileSync ( dotenvPath , { encoding : 'utf8' } ) ;
197
+ const sassPathMatch = sassPathRegex . exec ( dotenv ) ;
198
+
199
+ if ( sassPathMatch && sassPathMatch [ 1 ] ) {
200
+ const sassPaths = sassPathMatch [ 1 ] . split ( path . delimiter ) ;
201
+
202
+ // Manually convert relative paths in SASS_PATH to absolute,
203
+ // lest they be resolved relative to process.cwd which would almost certainly be wrong
204
+ for (
205
+ var i = 0 , currPath = sassPaths [ i ] ;
206
+ i < sassPaths . length ;
207
+ currPath = sassPaths [ ++ i ]
208
+ ) {
209
+ if ( path . isAbsolute ( currPath ) ) continue ;
210
+ sassPaths [ i ] = path . resolve ( projectDir , currPath ) ; // resolve path relative to project directory
211
+ }
212
+ // join modified array and assign to environment SASS_PATH
213
+ process . env . SASS_PATH = sassPaths . join ( path . delimiter ) ;
210
214
}
211
- // join modified array and assign to environment SASS_PATH
212
- process . env . SASS_PATH = sassPaths . join ( path . delimiter ) ;
213
- }
215
+ } catch { }
214
216
215
217
return info . languageService ;
216
218
}
0 commit comments