filesystem-sandbox
Advanced tools
Comparing version 1.11.0 to 1.12.0
@@ -35,2 +35,5 @@ /// <reference types="node" /> | ||
static create(at?: string): Promise<Sandbox>; | ||
static setBaseTargetToCurrentWorkingDirectory(): Promise<void>; | ||
static setBaseTargetToSystemTempFolder(): Promise<void>; | ||
static setBaseTarget(to: string): Promise<void>; | ||
} |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -8,2 +27,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const fs_1 = require("fs"); | ||
const os = __importStar(require("os")); | ||
if (!fs_1.promises) { | ||
@@ -49,2 +69,3 @@ throw new Error("Yer node is olde! filesystem-sandboxes requires a Node with fs.promises"); | ||
exports.basePrefix = "__sandboxes__"; | ||
let baseTarget = os.tmpdir(); | ||
const sandboxes = []; | ||
@@ -54,3 +75,3 @@ class Sandbox { | ||
this._at = at; | ||
this._base = path_1.default.join(at || process.cwd(), exports.basePrefix); | ||
this._base = path_1.default.join(at || baseTarget, exports.basePrefix); | ||
this._path = path_1.default.join(this._base, uuid_1.v4()); | ||
@@ -160,3 +181,15 @@ mkdirp_1.sync(this._path); | ||
} | ||
static async setBaseTargetToCurrentWorkingDirectory() { | ||
await this.setBaseTarget(process.cwd()); | ||
} | ||
static async setBaseTargetToSystemTempFolder() { | ||
await this.setBaseTarget(os.tmpdir()); | ||
} | ||
static async setBaseTarget(to) { | ||
if (!(await isFolder(to))) { | ||
await mkdirp_1.sync(to); | ||
} | ||
baseTarget = to; | ||
} | ||
} | ||
exports.Sandbox = Sandbox; |
{ | ||
"name": "filesystem-sandbox", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "JavaScript module to provide filesystem sandboxes for testing", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13382
229