Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / v8-compile-cache / v8-compile-cache.js
index 69f053667046ca2a4f6e3ce66d5cd307ebc3d1bd..b9c09288cb310b8301bf02f42592c2a8a8a34fad 100644 (file)
@@ -86,8 +86,6 @@ class FileSystemBlobStore {
     try {
       fs.writeFileSync(this._blobFilename, blobToStore);
       fs.writeFileSync(this._mapFilename, mapToStore);
-    } catch (error) {
-      throw error;
     } finally {
       fs.unlinkSync(this._lockFilename);
     }
@@ -301,7 +299,8 @@ function slashEscape(str) {
     '\x00': 'z0',
     'z': 'zZ',
   };
-  return str.replace(/[\\:\/\x00z]/g, match => (ESCAPE_LOOKUP[match]));
+  const ESCAPE_REGEX = /[\\:/\x00z]/g; // eslint-disable-line no-control-regex
+  return str.replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]);
 }
 
 function supportsCachedData() {
@@ -311,6 +310,11 @@ function supportsCachedData() {
 }
 
 function getCacheDir() {
+  const v8_compile_cache_cache_dir = process.env.V8_COMPILE_CACHE_CACHE_DIR;
+  if (v8_compile_cache_cache_dir) {
+    return v8_compile_cache_cache_dir;
+  }
+
   // Avoid cache ownership issues on POSIX systems.
   const dirname = typeof process.getuid === 'function'
     ? 'v8-compile-cache-' + process.getuid()
@@ -348,7 +352,7 @@ if (!process.env.DISABLE_V8_COMPILE_CACHE && supportsCachedData()) {
   nativeCompileCache.setCacheStore(blobStore);
   nativeCompileCache.install();
 
-  process.once('exit', code => {
+  process.once('exit', () => {
     if (blobStore.isDirty()) {
       blobStore.save();
     }