Skip to content

Commit

Permalink
fix: fixed browser stat sync check
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Aug 17, 2020
1 parent 942e5e1 commit 31c64de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div id="app"></div>
<script src="https://unpkg.com/docute-emojify@0.1" type="text/javascript"></script>
<script src="https://unpkg.com/docute@3/dist/docute.js" type="text/javascript"></script>
<script src="https://unpkg.com/bree@2.1.2/dist/bree.js"></script>
<script src="https://unpkg.com/bree@2.1.3/dist/bree.js"></script>
<script src="./config.js" type="text/javascript"></script>
</body>
</html>
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const threads = require('bthreads');
const { boolean } = require('boolean');
const { setTimeout, setInterval } = require('safe-timers');

const hasFsStatSync =
typeof fs === 'object' && typeof fs.statSync === 'function';

class Bree extends EventEmitter {
constructor(config) {
super();
Expand Down Expand Up @@ -100,7 +103,7 @@ class Bree extends EventEmitter {
// validate root (sync check)
if (isSANB(this.config.root)) {
/* istanbul ignore next */
if (typeof fs === 'object') {
if (hasFsStatSync) {
const stats = fs.statSync(this.config.root);
if (!stats.isDirectory())
throw new Error(
Expand Down Expand Up @@ -212,7 +215,7 @@ class Bree extends EventEmitter {
);
try {
/* istanbul ignore next */
if (typeof fs === 'object') {
if (hasFsStatSync) {
const stats = fs.statSync(path);
if (!stats.isFile())
throw new Error(`Job #${i + 1} "${job}" path missing: ${path}`);
Expand Down Expand Up @@ -308,7 +311,7 @@ class Bree extends EventEmitter {
if (path) {
try {
/* istanbul ignore next */
if (typeof fs === 'object') {
if (hasFsStatSync) {
const stats = fs.statSync(path);
// eslint-disable-next-line max-depth
if (!stats.isFile())
Expand Down

0 comments on commit 31c64de

Please sign in to comment.