UNPKG

1.77 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.cleanupTestModule = exports.resetTestModule = exports.resetMSVSVersion = exports.TIMEOUT_IN_MILLISECONDS = exports.MINUTES_IN_MILLISECONDS = void 0;
7const fs_extra_1 = __importDefault(require("fs-extra"));
8const path_1 = __importDefault(require("path"));
9const cross_spawn_promise_1 = require("@malept/cross-spawn-promise");
10const originalGypMSVSVersion = process.env.GYP_MSVS_VERSION;
11const TIMEOUT_IN_MINUTES = process.platform === 'win32' ? 5 : 2;
12exports.MINUTES_IN_MILLISECONDS = 60 * 1000;
13exports.TIMEOUT_IN_MILLISECONDS = TIMEOUT_IN_MINUTES * exports.MINUTES_IN_MILLISECONDS;
14function resetMSVSVersion() {
15 if (originalGypMSVSVersion) {
16 process.env.GYP_MSVS_VERSION = originalGypMSVSVersion;
17 }
18}
19exports.resetMSVSVersion = resetMSVSVersion;
20async function resetTestModule(testModulePath, installModules = true) {
21 await fs_extra_1.default.remove(testModulePath);
22 await fs_extra_1.default.mkdir(testModulePath, { recursive: true });
23 await fs_extra_1.default.copyFile(path_1.default.resolve(__dirname, '../../test/fixture/native-app1/package.json'), path_1.default.resolve(testModulePath, 'package.json'));
24 if (installModules) {
25 await (0, cross_spawn_promise_1.spawn)('npm', ['install'], { cwd: testModulePath });
26 }
27 resetMSVSVersion();
28}
29exports.resetTestModule = resetTestModule;
30async function cleanupTestModule(testModulePath) {
31 await fs_extra_1.default.remove(testModulePath);
32 resetMSVSVersion();
33}
34exports.cleanupTestModule = cleanupTestModule;
35//# sourceMappingURL=module-setup.js.map
\No newline at end of file