Skip to content

Commit

Permalink
Remove deprecated project.root
Browse files Browse the repository at this point in the history
  • Loading branch information
lolmaus committed Aug 3, 2023
1 parent ab71564 commit 4e290a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 39 deletions.
32 changes: 11 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ project.pkg; // => the contents of package.json for the given project
project.files; // => read or write the set of files further

// if you don't set this, a new temp dir will be made for you when you writeSync()
project.baseDir = 'some/root/';
project.baseDir = 'some/base/dir/';

await project.write();

Expand All @@ -40,10 +40,10 @@ The above example produces the following files (and most importantly the
appropriate file contents:

```sh
some/root/package.json
some/root/index.js
some/root/node_modules/mocha/package.json
some/root/node_modules/chai/package.json
some/base/dir/package.json
some/base/dir/index.js
some/base/dir/node_modules/mocha/package.json
some/base/dir/node_modules/chai/package.json
```

### Nesting Dependencies
Expand Down Expand Up @@ -136,12 +136,11 @@ appropriate for apps) you can use `linkDevDeps` instead.
- [Linking to real dependencies](#linking-to-real-dependencies)
- [API](#api)
- [Project](#project)
- [~~project.root~~](#projectroot)
- [project.baseDir](#projectbasedir)
- [project.baseDir](#projectbasedir-1)
- [project.name : <code>string</code>](#projectname--string)
- [project.name : string](#projectname--string)
- [project.name](#projectname)
- [project.version : <code>string</code>](#projectversion--string)
- [project.version : string](#projectversion--string)
- [project.version](#projectversion)
- [project.mergeFiles(dirJSON)](#projectmergefilesdirjson)
- [project.write(dirJSON?)](#projectwritedirjson)
Expand All @@ -156,16 +155,7 @@ appropriate for apps) you can use `linkDevDeps` instead.
- [project.devDependencyProjects() ⇒](#projectdevdependencyprojects-)
- [project.clone() ⇒](#projectclone-)
- [project.dispose()](#projectdispose)
- [Project.fromDir(root, opts) ⇒](#projectfromdirroot-opts-)

<a name="Project+root"></a>

### ~~project.root~~
***Deprecated***

**Kind**: instance property of [<code>Project</code>](#Project)
**Read only**: true
<a name="Project+baseDir"></a>
- [Project.fromDir(baseDir, opts) ⇒](#projectfromdirbasedir-opts-)

### project.baseDir
<p>Sets the base directory of the project.</p>
Expand Down Expand Up @@ -326,8 +316,8 @@ appropriate for apps) you can use `linkDevDeps` instead.
**Kind**: instance method of [<code>Project</code>](#Project)
<a name="Project.fromDir"></a>

### Project.fromDir(root, opts) ⇒
<p>Reads an existing project from the specified root.</p>
### Project.fromDir(baseDir, opts) ⇒
<p>Reads an existing project from the specified base dir.</p>

**Kind**: static method of [<code>Project</code>](#Project)
**Returns**: <ul>
Expand All @@ -336,7 +326,7 @@ appropriate for apps) you can use `linkDevDeps` instead.

| Param | Description |
| --- | --- |
| root | <p>The base directory to read the project from.</p> |
| baseDir | <p>The base directory to read the project from.</p> |
| opts | <p>An options object.</p> |
| opts.linkDeps | <p>Include linking dependencies from the Project's node_modules.</p> |
| opts.linkDevDeps | <p>Include linking devDependencies from the Project's node_modules.</p> |
Expand Down
26 changes: 8 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,6 @@ export class Project {
}
}

/**
* @deprecated Please use baseDir instead.
*
* @readonly
* @memberof Project
*/
get root() {
throw new Error('.root has been removed, please review the readme but you likely actually want .baseDir now');
}

/**
* Sets the base directory of the project.
*
Expand Down Expand Up @@ -210,17 +200,17 @@ export class Project {
}

/**
* Reads an existing project from the specified root.
* Reads an existing project from the specified base dir.
*
* @param root - The base directory to read the project from.
* @param baseDir - The base directory to read the project from.
* @param opts - An options object.
* @param opts.linkDeps - Include linking dependencies from the Project's node_modules.
* @param opts.linkDevDeps - Include linking devDependencies from the Project's node_modules.
* @returns - The deserialized Project.
*/
static fromDir(root: string, opts?: ReadDirOpts): Project {
static fromDir(baseDir: string, opts?: ReadDirOpts): Project {
let project = new Project();
project.readSync(root, opts);
project.readSync(baseDir, opts);
return project;
}

Expand Down Expand Up @@ -571,8 +561,8 @@ export class Project {
fs.copyFileSync(source, destination, fs.constants.COPYFILE_FICLONE | fs.constants.COPYFILE_EXCL);
}

private readSync(root: string, opts?: ReadDirOpts): void {
const files = fixturify.readSync(root, {
private readSync(baseDir: string, opts?: ReadDirOpts): void {
const files = fixturify.readSync(baseDir, {
// when linking deps, we don't need to crawl all of node_modules
ignore: opts?.linkDeps || opts?.linkDevDeps ? ['node_modules'] : [],
});
Expand All @@ -585,12 +575,12 @@ export class Project {
if (opts?.linkDeps || opts?.linkDevDeps) {
if (this.pkg.dependencies) {
for (let dep of Object.keys(this.pkg.dependencies)) {
this.linkDependency(dep, { baseDir: root });
this.linkDependency(dep, { baseDir });
}
}
if (this.pkg.devDependencies && opts.linkDevDeps) {
for (let dep of Object.keys(this.pkg.devDependencies)) {
this.linkDevDependency(dep, { baseDir: root });
this.linkDevDependency(dep, { baseDir });
}
}
} else {
Expand Down

0 comments on commit 4e290a4

Please sign in to comment.