-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #851 from ember-fastboot/fix-nm
Fix mocha tests nested packages in node_modules not using workspaces
- Loading branch information
Showing
5 changed files
with
82 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]} | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"experimentalDecorators": true | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"packages/**/node_modules", | ||
"test-packages/**/node_modules", | ||
"bower_components", | ||
"tmp", | ||
"vendor", | ||
".git", | ||
"dist" | ||
] | ||
} |
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,46 @@ | ||
/** | ||
* Fix nested packages not using workspace version | ||
* ember-cli-addon-tests will link ember-cli-fastboot and run npm install in the test apps, | ||
* the installation will install fastboot from npm registry rather than workspace version | ||
*/ | ||
|
||
import path from 'path'; | ||
import fs from 'fs-extra'; | ||
import { fileURLToPath } from 'url'; | ||
import chalk from 'chalk'; | ||
const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
|
||
const packagesDir = path.resolve(__dirname, '../../packages'); | ||
const nodeModulesDir = path.resolve(__dirname, 'node_modules'); | ||
|
||
// eslint-disable-next-line no-undef | ||
const shouldRestore = process.argv[2]; | ||
if (shouldRestore === '--help' || shouldRestore === '-h') { | ||
console.log(`Usage: node fix-node-modules.mjs [arguments] | ||
Options: | ||
-h, --help print this message | ||
-r, --restore restore node_modules by removing symlinks`); | ||
} else if (shouldRestore === '-r' || shouldRestore === '--restore') { | ||
run(true); | ||
} else { | ||
run(false); | ||
} | ||
|
||
function run(shouldRestore) { | ||
['fastboot', 'fastboot-express-middleware'].forEach((packageName) => { | ||
const nodeModulesPackageDir = path.join(nodeModulesDir, packageName); | ||
const workspacesPackageDir = path.resolve(packagesDir, packageName); | ||
if (fs.existsSync(nodeModulesPackageDir)) { | ||
console.log(chalk.blue(`remove ${nodeModulesPackageDir}`)); | ||
fs.removeSync(nodeModulesPackageDir); | ||
} | ||
if (!shouldRestore) { | ||
console.log( | ||
chalk.green( | ||
`symlink ${nodeModulesPackageDir} -> ${workspacesPackageDir}` | ||
) | ||
); | ||
fs.symlinkSync(workspacesPackageDir, nodeModulesPackageDir, 'dir'); | ||
} | ||
}); | ||
} |
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