fixturify-project
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -12,2 +12,3 @@ import fixturify from 'fixturify'; | ||
} | ||
declare type ProjectCallback = (project: Project) => void; | ||
export declare class Project { | ||
@@ -24,5 +25,8 @@ pkg: PackageJson; | ||
private linkIsDevDependency; | ||
constructor(name?: string, version?: string, args?: Omit<ProjectArgs, 'name' | 'version'>, projectCallback?: ProjectCallback); | ||
constructor(name?: string, version?: string, args?: Omit<ProjectArgs, 'name' | 'version'>); | ||
constructor(name?: string, args?: Omit<ProjectArgs, 'name'>); | ||
constructor(args?: ProjectArgs); | ||
constructor(name?: string, version?: string, projectCallback?: ProjectCallback); | ||
constructor(name?: string, args?: Omit<ProjectArgs, 'name'>, projectCallback?: ProjectCallback); | ||
constructor(args?: ProjectArgs, projectCallback?: ProjectCallback); | ||
get root(): void; | ||
set baseDir(dir: string); | ||
@@ -38,13 +42,15 @@ get baseDir(): string; | ||
private readSync; | ||
addDependency(name?: string, version?: string, args?: Omit<ProjectArgs, 'name' | 'version'>): Project; | ||
addDependency(name?: string, args?: Omit<ProjectArgs, 'name'>): Project; | ||
addDependency(args?: ProjectArgs): Project; | ||
addDependency(args?: Project): Project; | ||
addDependency(name?: string, version?: string, args?: Omit<ProjectArgs, 'name' | 'version'>, projectCallback?: ProjectCallback): Project; | ||
addDependency(name?: string, version?: string, projectCallback?: ProjectCallback): Project; | ||
addDependency(name?: string, args?: Omit<ProjectArgs, 'name'>, projectCallback?: ProjectCallback): Project; | ||
addDependency(args?: ProjectArgs, projectCallback?: ProjectCallback): Project; | ||
addDependency(args?: Project, projectCallback?: ProjectCallback): Project; | ||
private addDep; | ||
removeDependency(name: string): void; | ||
removeDevDependency(name: string): void; | ||
addDevDependency(name?: string, version?: string, args?: Omit<ProjectArgs, 'name' | 'version'>): Project; | ||
addDevDependency(name?: string, args?: Omit<ProjectArgs, 'name'>): Project; | ||
addDevDependency(args?: ProjectArgs): Project; | ||
addDevDependency(args?: Project): Project; | ||
addDevDependency(name?: string, version?: string, args?: Omit<ProjectArgs, 'name' | 'version'>, projectCallback?: ProjectCallback): Project; | ||
addDevDependency(name?: string, version?: string, projectCallback?: ProjectCallback): Project; | ||
addDevDependency(name?: string, args?: Omit<ProjectArgs, 'name'>, projectCallback?: ProjectCallback): Project; | ||
addDevDependency(args?: ProjectArgs, projectCallback?: ProjectCallback): Project; | ||
addDevDependency(args?: Project, projectCallback?: ProjectCallback): Project; | ||
linkDependency(name: string, opts: { | ||
@@ -51,0 +57,0 @@ baseDir: string; |
73
index.js
@@ -24,2 +24,5 @@ "use strict"; | ||
} | ||
function isProjectCallback(maybe) { | ||
return typeof maybe === 'function'; | ||
} | ||
function getString(obj, propertyName, errorMessage) { | ||
@@ -90,3 +93,3 @@ const value = obj[propertyName]; | ||
class Project { | ||
constructor(first, second, third) { | ||
constructor(first, second, third, fourth) { | ||
this.isDependency = true; | ||
@@ -109,3 +112,5 @@ this._dependencies = {}; | ||
if (third) { | ||
({ files, requestedRange } = third); | ||
if (!isProjectCallback(third)) { | ||
({ files, requestedRange } = third); | ||
} | ||
} | ||
@@ -115,3 +120,5 @@ } | ||
if (second) { | ||
({ version, files, requestedRange } = second); | ||
if (!isProjectCallback(second)) { | ||
({ version, files, requestedRange } = second); | ||
} | ||
} | ||
@@ -141,3 +148,14 @@ } | ||
this.requestedRange = requestedRange || this.pkg.version; | ||
const arity = arguments.length; | ||
if (arity > 1) { | ||
fourth; | ||
const projectCallback = arguments[arity - 1]; | ||
if (isProjectCallback(projectCallback)) { | ||
projectCallback(this); | ||
} | ||
} | ||
} | ||
get root() { | ||
throw new Error('.root has been removed, please review the readme but you likely actually want .baseDir now'); | ||
} | ||
set baseDir(dir) { | ||
@@ -226,6 +244,21 @@ if (this._baseDir) { | ||
} | ||
addDependency(first, second, third) { | ||
return this.addDep(first, second, third, '_dependencies'); | ||
addDependency(first, second, third, fourth) { | ||
let projectCallback; | ||
const arity = arguments.length; | ||
if (arity > 1) { | ||
fourth; | ||
const maybeProjectCallback = arguments[arity - 1]; | ||
if (isProjectCallback(maybeProjectCallback)) { | ||
projectCallback = maybeProjectCallback; | ||
} | ||
} | ||
if (isProjectCallback(second)) { | ||
second = undefined; | ||
} | ||
if (isProjectCallback(third)) { | ||
third = undefined; | ||
} | ||
return this.addDep(first, second, third, '_dependencies', projectCallback); | ||
} | ||
addDep(first, second, third, target) { | ||
addDep(first, second, third, target, projectCallback) { | ||
let dep; | ||
@@ -239,6 +272,6 @@ if (first == null) { | ||
let version = second; | ||
dep = new Project(name, version, third); | ||
dep = new Project(name, version, third, projectCallback); | ||
} | ||
else { | ||
dep = new Project(name, second); | ||
dep = new Project(name, second, projectCallback); | ||
} | ||
@@ -250,3 +283,3 @@ } | ||
else { | ||
dep = new Project(first); | ||
dep = new Project(first, projectCallback); | ||
} | ||
@@ -256,2 +289,5 @@ this[target][dep.name] = dep; | ||
this.linkIsDevDependency.delete(dep.name); | ||
if (isProjectCallback(projectCallback)) { | ||
projectCallback(this); | ||
} | ||
return dep; | ||
@@ -269,4 +305,19 @@ } | ||
} | ||
addDevDependency(first, second, third) { | ||
return this.addDep(first, second, third, '_devDependencies'); | ||
addDevDependency(first, second, third, fourth) { | ||
let projectCallback; | ||
const arity = arguments.length; | ||
if (arity > 1) { | ||
fourth; | ||
const maybeProjectCallback = arguments[arity - 1]; | ||
if (isProjectCallback(maybeProjectCallback)) { | ||
projectCallback = maybeProjectCallback; | ||
} | ||
} | ||
if (isProjectCallback(second)) { | ||
second = undefined; | ||
} | ||
if (isProjectCallback(third)) { | ||
third = undefined; | ||
} | ||
return this.addDep(first, second, third, '_devDependencies', projectCallback); | ||
} | ||
@@ -273,0 +324,0 @@ linkDependency(name, opts) { |
{ | ||
"name": "fixturify-project", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"main": "index.js", | ||
@@ -33,3 +33,3 @@ "repository": "git@github.com:stefanpenner/node-fixturify-project", | ||
"test": "mocha test -r source-map-support/register", | ||
"test:debug": "mocha debug test -r source-map-support/register", | ||
"test:inspect": "mocha inspect test -r source-map-support/register", | ||
"lint": "yarn prettier --check *.ts", | ||
@@ -36,0 +36,0 @@ "prepare": "tsc", |
@@ -16,3 +16,3 @@ # node-fixturify-project | ||
```js | ||
const Project = require('fixturify-project'); | ||
const { Project } = require('fixturify-project'); | ||
const project = new Project('rsvp', '3.1.4', { | ||
@@ -54,3 +54,3 @@ files: { | ||
```js | ||
const Project = require('fixturify-project'); | ||
const { Project } = require('fixturify-project'); | ||
@@ -82,3 +82,3 @@ let project = new Project('rsvp'); | ||
```js | ||
const Project = require('fixturify-project'); | ||
const { Project } = require('fixturify-project'); | ||
@@ -85,0 +85,0 @@ let project = new 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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21909
5
473
0