Skip to content

Commit

Permalink
refactor: not use reserved keyword package
Browse files Browse the repository at this point in the history
  • Loading branch information
pablo1v committed Mar 15, 2021
1 parent b5af7e8 commit 0fc902f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ const { ROOT_PATH } = require('./shared/constants');
const { getWorkspacesPackages } = require('./shared/getWorkspacesPackages');

const projects = getWorkspacesPackages(false)
.filter(package => existsSync(join(ROOT_PATH, package, 'jest.config.js')))
.map(package => `<rootDir>/${package}/jest.config.js`);
.filter(packageName =>
existsSync(join(ROOT_PATH, packageName, 'jest.config.js')),
)
.map(packageName => `<rootDir>/${packageName}/jest.config.js`);

module.exports = {
projects,
Expand Down
4 changes: 2 additions & 2 deletions scripts/test-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const { getWorkspacesPackages } = require('../shared/getWorkspacesPackages');
const packages = getWorkspacesPackages();

async function testAll() {
for await (const package of packages) {
const cwd = join(ROOT_PATH, package);
for await (const packageName of packages) {
const cwd = join(ROOT_PATH, packageName);

await exec('yarn jest --passWithNoTests', cwd);
}
Expand Down
12 changes: 6 additions & 6 deletions shared/getWorkspacesPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ function isDirectory(path) {

/**
* @param {string} workspace
* @param {string} package
* @param {string} packageName
* @return {string}
*/
function makePackagePath(workspace, package) {
function makePackagePath(workspace, packageName) {
if (['', '/'].includes(workspace)) {
return package;
return packageName;
}

return `${workspace}/${package}`;
return `${workspace}/${packageName}`;
}

/**
Expand All @@ -73,8 +73,8 @@ function getPackages(workspace) {
const mappedPackages = readdirSync(path);

return mappedPackages
.filter(package => isDirectory(join(path, package)))
.map(package => makePackagePath(workspaceCleaned, package));
.filter(packageName => isDirectory(join(path, packageName)))
.map(packageName => makePackagePath(workspaceCleaned, packageName));
}

module.exports = {
Expand Down

0 comments on commit 0fc902f

Please sign in to comment.