-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dcba004
commit ae15022
Showing
4 changed files
with
55 additions
and
58 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,6 +156,7 @@ module.exports = { | |
'ver', | ||
'wip', | ||
'workspace', | ||
'workspaces', | ||
'yargs', | ||
'zsh' | ||
], | ||
|
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,39 @@ | ||
const { lstatSync, readdirSync } = require('fs') | ||
const { resolve } = require('path') | ||
|
||
/** | ||
* @file Scripts - Workspaces | ||
* @module scripts/workspaces | ||
*/ | ||
|
||
/** | ||
* Returns an array containing Yarn workspace directory names. | ||
* | ||
* @return {string[]} Array containing workspace directory names | ||
*/ | ||
const workspaces = () => { | ||
// Yarn project names | ||
const projects = ['packages'] | ||
|
||
/** | ||
* Returns an array containing Yarn workspaces listed under `project`. | ||
* | ||
* @param {string} project - Yarn project directory | ||
* @return {string[]} Yarn workspaces listed under `project` | ||
*/ | ||
const callback = project => { | ||
// Get path to Yarn project directory | ||
const path = resolve(process.env.PROJECT_CWD, project) | ||
|
||
// Add subdirectories under Yarn project directory | ||
return readdirSync(path).filter(workspace => { | ||
if (!lstatSync(resolve(path, workspace)).isDirectory()) return | ||
return workspace | ||
}) | ||
} | ||
|
||
// Return workspace directory names | ||
return projects.map(callback).flat() | ||
} | ||
|
||
module.exports = workspaces |