66 *
77 * @see https://github.com/babel/babel-loader/
88 */
9- import * as fs from "fs"
10- import * as os from "os"
11- import * as path from " path"
12- import * as zlib from " zlib"
13- import * as crypto from " crypto"
14- import * as findCacheDir from " find-cache-dir"
15- import * as makeDir from " make-dir"
16- import { promisify } from " util"
17- import { CacheOptions , TransformParams } from " ./types"
18- import { transform } from "."
9+ import * as fs from 'fs'
10+ import * as os from 'os'
11+ import * as path from ' path'
12+ import * as zlib from ' zlib'
13+ import * as crypto from ' crypto'
14+ import * as findCacheDir from ' find-cache-dir'
15+ import * as makeDir from ' make-dir'
16+ import { promisify } from ' util'
17+ import { CacheOptions , TransformParams } from ' ./types'
18+ import { transform } from '.'
1919
2020// Lazily instantiated when needed
2121let defaultCacheDirectory : string | null = null
@@ -33,7 +33,7 @@ const gzip = promisify(zlib.gzip)
3333 * @params {Boolean} compress
3434 */
3535const read = async function ( filename : string , compress : boolean ) {
36- const data = await readFile ( filename + ( compress ? " .gz" : "" ) )
36+ const data = await readFile ( filename + ( compress ? ' .gz' : '' ) )
3737 const content = compress ? await gunzip ( data ) : data
3838
3939 return JSON . parse ( content . toString ( ) )
@@ -51,7 +51,7 @@ const write = async function (filename: string, compress: boolean, result: strin
5151 const content = JSON . stringify ( result )
5252
5353 const data = compress ? await gzip ( content ) : content
54- return await writeFile ( filename + ( compress ? " .gz" : "" ) , data )
54+ return await writeFile ( filename + ( compress ? ' .gz' : '' ) , data )
5555}
5656
5757/**
@@ -63,13 +63,13 @@ const write = async function (filename: string, compress: boolean, result: strin
6363 * @return {String }
6464 */
6565const filename = function ( source : string , identifier : string ) {
66- const hash = crypto . createHash ( " md4" )
66+ const hash = crypto . createHash ( ' md4' )
6767
6868 const contents = JSON . stringify ( { source, identifier } )
6969
7070 hash . update ( contents )
7171
72- return hash . digest ( " hex" ) + " .json"
72+ return hash . digest ( ' hex' ) + ' .json'
7373}
7474
7575/**
@@ -95,7 +95,7 @@ const handleCache = async function (
9595 // continue regardless of error
9696 }
9797
98- const fallback = typeof cacheDirectory !== " string" && directory !== os . tmpdir ( )
98+ const fallback = typeof cacheDirectory !== ' string' && directory !== os . tmpdir ( )
9999
100100 // Make sure the directory exists.
101101 try {
@@ -138,11 +138,11 @@ const handleCache = async function (
138138export async function cache ( cacheOptions : CacheOptions , transformParams : TransformParams ) : Promise < string > {
139139 let directory
140140
141- if ( typeof cacheOptions . cacheDirectory === " string" ) {
141+ if ( typeof cacheOptions . cacheDirectory === ' string' ) {
142142 directory = cacheOptions . cacheDirectory
143143 } else {
144144 if ( defaultCacheDirectory === null ) {
145- defaultCacheDirectory = findCacheDir ( { name : " responsive-loader" } ) || os . tmpdir ( )
145+ defaultCacheDirectory = findCacheDir ( { name : ' responsive-loader' } ) || os . tmpdir ( )
146146 }
147147
148148 directory = defaultCacheDirectory
0 commit comments