fixturify-project
Advanced tools
Comparing version 4.1.0 to 4.1.1
import fixturify from 'fixturify'; | ||
import { PackageJson as BasePackageJson } from 'type-fest'; | ||
declare type PackageJson = BasePackageJson & { | ||
[name: string]: {}; | ||
}; | ||
declare type PackageJson = BasePackageJson & Record<string, any>; | ||
interface ReadDirOpts { | ||
@@ -48,3 +46,3 @@ linkDeps?: boolean; | ||
writeSync(): void; | ||
private writeProject; | ||
protected writeProject(): void; | ||
private binLinks; | ||
@@ -51,0 +49,0 @@ private writeLinkedPackage; |
72
index.js
@@ -14,3 +14,5 @@ "use strict"; | ||
const binLinks = require("bin-links"); | ||
const walk_sync_1 = require("walk-sync"); | ||
const walkSync = require("walk-sync"); | ||
const util_1 = require("util"); | ||
const { entries } = walkSync; | ||
tmp.setGracefulCleanup(); | ||
@@ -204,3 +206,2 @@ function deserializePackageJson(serialized) { | ||
writeSync() { | ||
console.warn('this method is deprecated, please use write instead'); | ||
this.writeProject(); | ||
@@ -225,8 +226,6 @@ } | ||
async binLinks() { | ||
for (let { pkg, baseDir: path } of this.dependencyProjects()) { | ||
let nodeModules = path.join(this.baseDir, 'node_modules'); | ||
for (const { pkg, path } of readPackages(nodeModules)) { | ||
await binLinks({ pkg, path, top: false, global: false, force: true }); | ||
} | ||
for (let { pkg, baseDir: path } of this.devDependencyProjects()) { | ||
await binLinks({ pkg, path, top: false, global: false, force: true }); | ||
} | ||
} | ||
@@ -262,3 +261,3 @@ writeLinkedPackage(name, target) { | ||
fs.ensureDirSync(destination); | ||
for (let entry of (0, walk_sync_1.entries)(target, { ignore: ['node_modules'] })) { | ||
for (let entry of entries(target, { ignore: ['node_modules'] })) { | ||
if (entry.isDirectory()) { | ||
@@ -487,2 +486,61 @@ fs.ensureDirSync(path.join(destination, entry.relativePath)); | ||
} | ||
function isErrnoException(e) { | ||
return e instanceof Error && 'code' in e; | ||
} | ||
function readString(name) { | ||
try { | ||
return fs.readFileSync(name, 'utf8'); | ||
} | ||
catch (e) { | ||
if (isErrnoException(e)) { | ||
if (e.code === 'ENOENT' || e.code === 'EISDIR') { | ||
return; | ||
} | ||
} | ||
throw e; | ||
} | ||
} | ||
function readdir(name) { | ||
try { | ||
return fs.readdirSync(name); | ||
} | ||
catch (e) { | ||
if (isErrnoException(e)) { | ||
if (e.code === 'ENOENT' || e.code === 'ENOTDIR') { | ||
return []; | ||
} | ||
} | ||
throw e; | ||
} | ||
} | ||
function readPackage(dir) { | ||
if (dir) { | ||
const fileName = path.join(dir, 'package.json'); | ||
const content = readString(fileName); | ||
if (content) { | ||
return { pkg: deserializePackageJson(content), path: dir }; | ||
} | ||
} | ||
return; | ||
} | ||
function readPackages(modulesPath) { | ||
const pkgs = []; | ||
for (const name of readdir(modulesPath)) { | ||
if (name.startsWith('@')) { | ||
const scopePath = path.join(modulesPath, name); | ||
for (const name of readdir(scopePath)) { | ||
const pkg = readPackage(path.join(scopePath, name)); | ||
if (pkg) | ||
pkgs.push(pkg); | ||
} | ||
} | ||
else { | ||
const pkg = readPackage(path.join(modulesPath, name)); | ||
if (pkg) | ||
pkgs.push(pkg); | ||
} | ||
} | ||
return pkgs; | ||
} | ||
Project.prototype.writeSync = (0, util_1.deprecate)(Project.prototype.writeSync, 'project.writeSync() is deprecated. Use await project.write() instead'); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "fixturify-project", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:stefanpenner/node-fixturify-project", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
28425
625
0