Skip to content

Commit f4c645a

Browse files
committed
Forgot try/catch around fs.readFileSync 😥
1 parent 08a5294 commit f4c645a

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/index.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -192,25 +192,27 @@ function init({ typescript: ts }: { typescript: typeof ts_module }) {
192192
// Manually open .env and parse just the SASS_PATH part,
193193
// because we don't *need* to apply the full .env to this environment,
194194
// 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);
210214
}
211-
// join modified array and assign to environment SASS_PATH
212-
process.env.SASS_PATH = sassPaths.join(path.delimiter);
213-
}
215+
} catch {}
214216

215217
return info.languageService;
216218
}

0 commit comments

Comments
 (0)