Skip to content

Commit fbb941c

Browse files
committed
fix: Peg Travis' Node.js 10 version to 10.4.1 for mock-fs support.
1 parent db44094 commit fbb941c

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ language: node_js
66

77
node_js:
88
- "8"
9-
- "10"
9+
- "10.4.1"
1010

1111
env:
1212
- CXX=g++-4.8

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"markdown-toc": "^1.2.0",
3333
"mocha": "^3.4.2",
3434
"mocha-typescript": "^1.0.23",
35-
"mock-fs": "^4.3.0",
35+
"mock-fs": "4.6.0",
3636
"mock-require": "^2.0.2",
3737
"outdent": "^0.4.1",
3838
"perfectionist": "^2.4.0",

packages/@css-blocks/jsx/src/Analyzer/index.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { some, unwrap } from "@opticss/util";
88
import traverse from "babel-traverse";
99
import * as babylon from "babylon";
1010
import * as debugGenerator from "debug";
11-
import * as fs from "fs";
11+
import * as fs from "fs-extra";
1212
import * as path from "path";
1313

1414
import { CssBlocksJSXOptions } from "../options";
@@ -143,15 +143,14 @@ export class CSSBlocksJSXAnalyzer extends Analyzer<TEMPLATE_TYPE> {
143143
* @param file The file path to read in and parse.
144144
* @param opts Optional analytics parser options.
145145
*/
146-
public parseFile(file: string): Promise<JSXAnalysis> {
146+
public async parseFile(file: string): Promise<JSXAnalysis> {
147+
let data;
147148
file = path.resolve(this.options.baseDir, file);
148-
return new Promise((resolve, reject) => {
149-
fs.readFile(file, "utf8", (err, data) => {
150-
if (err) {
151-
reject(new JSXParseError(`Cannot read JSX entry point file ${file}: ${err.message}`, { filename: file }));
152-
}
153-
resolve(this.parse(file, data));
154-
});
155-
});
149+
try {
150+
data = await fs.readFile(file, "utf8");
151+
} catch (err) {
152+
throw new JSXParseError(`Cannot read JSX entry point file ${file}: ${err.message}`, { filename: file });
153+
}
154+
return this.parse(file, data);
156155
}
157156
}

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -9372,7 +9372,7 @@ mocha@^3.4.2:
93729372
mkdirp "0.5.1"
93739373
supports-color "3.1.2"
93749374

9375-
mock-fs@^4.3.0:
9375+
mock-fs@4.6.0:
93769376
version "4.6.0"
93779377
resolved "https://registry.npmjs.org/mock-fs/-/mock-fs-4.6.0.tgz#d944ef4c3e03ceb4e8332b4b31b8ac254051c8ae"
93789378

0 commit comments

Comments
 (0)