@coder/requirefs
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -17,3 +17,2 @@ "use strict"; | ||
var path = require("path"); | ||
var Zip = require("jszip"); | ||
var tar_1 = require("./tar"); | ||
@@ -66,5 +65,6 @@ var resolver_1 = require("./resolver"); | ||
var exports = module.exports; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
// @ts-ignore | ||
var __dirname = path.dirname(resolvedPath); | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
// @ts-ignore | ||
var require = function (target) { | ||
@@ -77,4 +77,5 @@ var nativeModule = _this.tryNativeRequire(target); | ||
}; | ||
/* eslint-enable @typescript-eslint/no-unused-vars */ | ||
var content = this.readFile(resolvedPath); | ||
if (resolvedPath.endsWith(".json")) { | ||
if (/\.json$/.test(resolvedPath)) { | ||
exports = JSON.parse(content); | ||
@@ -118,3 +119,3 @@ } | ||
exists: function (filePath) { | ||
return !filePath.endsWith("/") && !!tar.getFile(filePath); | ||
return !/\/$/.test(filePath) && !!tar.getFile(filePath); | ||
}, | ||
@@ -134,3 +135,4 @@ read: function (filePath) { | ||
exports.fromZip = function (content) { | ||
var zip = new Zip(content); | ||
// @ts-ignore | ||
var zip = new (require("jszip"))(content); | ||
return new RequireFS({ | ||
@@ -137,0 +139,0 @@ exists: function (filePath) { |
@@ -15,3 +15,3 @@ "use strict"; | ||
this._extensions = extensions.map(function (extension) { | ||
return extension.startsWith(".") ? extension : "." + extension; | ||
return /^\./.test(extension) ? extension : "." + extension; | ||
}); | ||
@@ -18,0 +18,0 @@ }, |
{ | ||
"name": "@coder/requirefs", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"license": "MIT", | ||
@@ -34,5 +34,7 @@ "author": "Coder", | ||
"dependencies": { | ||
"jszip": "2.6.0", | ||
"tar-stream": "^2.1.0" | ||
}, | ||
"optionalDependencies": { | ||
"jszip": "2.6.0" | ||
} | ||
} |
import * as path from "path" | ||
import * as Zip from "jszip" | ||
import { Tar } from "./tar" | ||
@@ -65,6 +64,7 @@ import { Resolver } from "./resolver" | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
// @ts-ignore | ||
const __dirname = path.dirname(resolvedPath) | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
// @ts-ignore | ||
const require = (target: string): Module => { | ||
@@ -77,5 +77,6 @@ const nativeModule = this.tryNativeRequire(target) | ||
} | ||
/* eslint-enable @typescript-eslint/no-unused-vars */ | ||
const content = this.readFile(resolvedPath) | ||
if (resolvedPath.endsWith(".json")) { | ||
if (/\.json$/.test(resolvedPath)) { | ||
exports = JSON.parse(content) | ||
@@ -121,3 +122,3 @@ } else { | ||
exists: (filePath: string): boolean => { | ||
return !filePath.endsWith("/") && !!tar.getFile(filePath) | ||
return !/\/$/.test(filePath) && !!tar.getFile(filePath) | ||
}, | ||
@@ -138,3 +139,4 @@ read: (filePath: string): string => { | ||
export const fromZip = (content: Uint8Array): RequireFS => { | ||
const zip = new Zip(content) | ||
// @ts-ignore | ||
const zip = new (require("jszip") as typeof import("jszip"))(content) | ||
return new RequireFS({ | ||
@@ -141,0 +143,0 @@ exists: (filePath: string): boolean => { |
@@ -15,3 +15,3 @@ import * as path from "path" | ||
this._extensions = extensions.map((extension) => { | ||
return extension.startsWith(".") ? extension : `.${extension}` | ||
return /^\./.test(extension) ? extension : `.${extension}` | ||
}) | ||
@@ -18,0 +18,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
44711
866
- Removedjszip@2.6.0