-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schema): developers can specify manually the path of the .forest…
…admin-schema.json file (#698) co-authored with @julienfouilhe
- Loading branch information
1 parent
db0ea3d
commit c27bfb9
Showing
7 changed files
with
117 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class ProjectDirectoryFinder { | ||
constructor({ path }) { | ||
this.path = path; | ||
this.dirname = __dirname; | ||
|
||
// NOTICE: Order does matter as packages install via yarn 2 Plug n Play mode also | ||
// include node_modules in path. | ||
this.PATHS_ROOT_PACKAGES = [ | ||
// Yarn 2 Plug n Play mode | ||
this.path.join('.yarn', 'cache'), | ||
this.path.join('.yarn', 'unplugged'), | ||
// Usual Yarn / NPM | ||
'node_modules', | ||
]; | ||
} | ||
|
||
ensureAbsolutePath(subPathsToProject) { | ||
// NOTICE: on POSIX system, empty path created by previous split is skipped by path.join. | ||
if (!this.path.isAbsolute(this.path.join(...subPathsToProject))) { | ||
return this.path.join(this.path.sep, ...subPathsToProject); | ||
} | ||
return this.path.join(...subPathsToProject); | ||
} | ||
|
||
getAbsolutePath() { | ||
for (let index = 0; index <= this.PATHS_ROOT_PACKAGES.length; index += 1) { | ||
const rootPackagesPath = this.PATHS_ROOT_PACKAGES[index]; | ||
// NOTICE: forest-express has not been sym linked. | ||
if (this.dirname.includes(rootPackagesPath)) { | ||
const indexRootPath = this.dirname.indexOf(rootPackagesPath); | ||
const pathProjectRoot = this.dirname.substr(0, indexRootPath); | ||
const subPathsToProject = pathProjectRoot.split(this.path.sep); | ||
return this.ensureAbsolutePath(subPathsToProject); | ||
} | ||
} | ||
|
||
// NOTICE: forest-express is sym linked, assuming the process is running on project directory. | ||
return process.cwd(); | ||
} | ||
} | ||
|
||
module.exports = ProjectDirectoryFinder; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters