mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-23 06:12:00 +01:00
Check fs.existsSync() before running fs.statSync() (#812)
This produces non-negligible speed improvements for Node users with lots of imports.
This commit is contained in:
parent
d9ebb5eff0
commit
35880d171f
@ -1,3 +1,7 @@
|
|||||||
|
## 1.22.12
|
||||||
|
|
||||||
|
* Improve the performance of Node.js compilation involving many `@import`s.
|
||||||
|
|
||||||
## 1.22.11
|
## 1.22.11
|
||||||
|
|
||||||
* Don't try to load unquoted plain-CSS indented-syntax imports.
|
* Don't try to load unquoted plain-CSS indented-syntax imports.
|
||||||
|
@ -156,23 +156,39 @@ String _cleanErrorMessage(_SystemError error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool fileExists(String path) {
|
bool fileExists(String path) {
|
||||||
try {
|
return _systemErrorToFileSystemException(() {
|
||||||
return _fs.statSync(path).isFile();
|
// `existsSync()` is faster than `statSync()`, but it doesn't clarify
|
||||||
} catch (error) {
|
// whether the entity in question is a file or a directory. Since false
|
||||||
var systemError = error as _SystemError;
|
// negatives are much more common than false positives, it works out in our
|
||||||
if (systemError.code == 'ENOENT') return false;
|
// favor to check this first.
|
||||||
rethrow;
|
if (!_fs.existsSync(path)) return false;
|
||||||
}
|
|
||||||
|
try {
|
||||||
|
return _fs.statSync(path).isFile();
|
||||||
|
} catch (error) {
|
||||||
|
var systemError = error as _SystemError;
|
||||||
|
if (systemError.code == 'ENOENT') return false;
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dirExists(String path) {
|
bool dirExists(String path) {
|
||||||
try {
|
return _systemErrorToFileSystemException(() {
|
||||||
return _fs.statSync(path).isDirectory();
|
// `existsSync()` is faster than `statSync()`, but it doesn't clarify
|
||||||
} catch (error) {
|
// whether the entity in question is a file or a directory. Since false
|
||||||
var systemError = error as _SystemError;
|
// negatives are much more common than false positives, it works out in our
|
||||||
if (systemError.code == 'ENOENT') return false;
|
// favor to check this first.
|
||||||
rethrow;
|
if (!_fs.existsSync(path)) return false;
|
||||||
}
|
|
||||||
|
try {
|
||||||
|
return _fs.statSync(path).isDirectory();
|
||||||
|
} catch (error) {
|
||||||
|
var systemError = error as _SystemError;
|
||||||
|
if (systemError.code == 'ENOENT') return false;
|
||||||
|
rethrow;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ensureDir(String path) {
|
void ensureDir(String path) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: sass
|
name: sass
|
||||||
version: 1.22.11
|
version: 1.22.12-dev
|
||||||
description: A Sass implementation in Dart.
|
description: A Sass implementation in Dart.
|
||||||
author: Sass Team
|
author: Sass Team
|
||||||
homepage: https://github.com/sass/dart-sass
|
homepage: https://github.com/sass/dart-sass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user