/** * @license Copyright 2017 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ 'use strict'; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const path_1 = require("path"); const child_process_1 = require("child_process"); const mkdirp = require("mkdirp"); function defaults(val, def) { return typeof val === 'undefined' ? def : val; } exports.defaults = defaults; function delay(time) { return __awaiter(this, void 0, void 0, function* () { return new Promise(resolve => setTimeout(resolve, time)); }); } exports.delay = delay; function makeTmpDir() { switch (process.platform) { case 'darwin': case 'linux': return makeUnixTmpDir(); case 'win32': return makeWin32TmpDir(); default: throw new Error(`Platform ${process.platform} is not supported`); } } exports.makeTmpDir = makeTmpDir; function makeUnixTmpDir() { return child_process_1.execSync('mktemp -d -t lighthouse.XXXXXXX').toString().trim(); } function makeWin32TmpDir() { const winTmpPath = process.env.TEMP || process.env.TMP || (process.env.SystemRoot || process.env.windir) + '\\temp'; const randomNumber = Math.floor(Math.random() * 9e7 + 1e7); const tmpdir = path_1.join(winTmpPath, 'lighthouse.' + randomNumber); mkdirp.sync(tmpdir); return tmpdir; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJ1dGlscy50cyJdLCJ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