fixturify-project
Advanced tools
Comparing version 1.5.3 to 1.6.0
22
index.js
@@ -18,3 +18,3 @@ 'use strict'; | ||
module.exports = class Project { | ||
constructor(name, version = '0.0.0', cb) { | ||
constructor(name, version = '0.0.0', cb, root) { | ||
this.pkg = { | ||
@@ -35,4 +35,8 @@ name, | ||
this.isDependency = true; | ||
this._tmp = tmp.dirSync({ unsafeCleanup: true }); | ||
this._root = fs.realpathSync(this._tmp.name); | ||
if (root) { | ||
this._root = root; | ||
} else { | ||
this._tmp = tmp.dirSync({ unsafeCleanup: true }); | ||
this._root = fs.realpathSync(this._tmp.name); | ||
} | ||
@@ -48,2 +52,6 @@ if (typeof cb === 'function') { | ||
get baseDir() { | ||
return `${this._root}/${this.name}`; | ||
} | ||
get name() { | ||
@@ -141,3 +149,3 @@ return this.pkg.name; | ||
if (typeof name === 'string') { | ||
dep = this._dependencies[name] = new this.constructor(name, version); | ||
dep = this._dependencies[name] = new this.constructor(name, version, null, `${this.root}/${this.name}/node_modules`); | ||
} else if (name.isDependency) { | ||
@@ -168,3 +176,3 @@ dep = this._dependencies[name.name] = name; | ||
if (typeof name === 'string') { | ||
dep = this._devDependencies[name] = new this.constructor(name, version); | ||
dep = this._devDependencies[name] = new this.constructor(name, version, null, `${this.root}/${this.name}/node_modules`); | ||
} else if (name.isDependency) { | ||
@@ -228,3 +236,5 @@ dep = this._devDependencies[name.name] = name; | ||
dispose() { | ||
this._tmp.removeCallback(); | ||
if (this._tmp) { | ||
this._tmp.removeCallback(); | ||
} | ||
} | ||
@@ -231,0 +241,0 @@ } |
{ | ||
"name": "fixturify-project", | ||
"version": "1.5.3", | ||
"version": "1.6.0", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:stefanpenner/node-fixturify-project", |
@@ -25,4 +25,4 @@ 'use strict'; | ||
project.files['index.js'] = `module.exports = "Hello, World!";`; | ||
project.addDependency('ember-cli', '3.1.1', cli => cli.addDependency('console-ui', '3.3.3')).addDependency('rsvp', '3.1.4'); | ||
project.addDevDependency('ember-source', '3.1.1'); | ||
let rsvp = project.addDependency('ember-cli', '3.1.1', cli => cli.addDependency('console-ui', '3.3.3')).addDependency('rsvp', '3.1.4'); | ||
let source = project.addDevDependency('ember-source', '3.1.1'); | ||
project.addDevDependency('@ember/ordered-set', '3.1.1'); | ||
@@ -34,2 +34,7 @@ project.writeSync(); | ||
expect(rsvp.root).to.eql(`${project.root}/rsvp/node_modules/ember-cli/node_modules`); | ||
expect(source.root).to.eql(`${project.root}/rsvp/node_modules`); | ||
expect(rsvp.baseDir).to.eql(`${project.root}/rsvp/node_modules/ember-cli/node_modules/rsvp`); | ||
expect(source.baseDir).to.eql(`${project.root}/rsvp/node_modules/ember-source`); | ||
expect(read(`${project.root}/rsvp/index.js`)).to.eql(`module.exports = "Hello, World!";`); | ||
@@ -36,0 +41,0 @@ |
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
27636
448