From e320f343f8d18a301bc1d74dcb2816e3d1e3be6f Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 26 Jul 2018 14:14:14 +0200 Subject: Add support for testing installations post-publish as well --- package.json | 1 + packages/monorepo-scripts/src/test_installation.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 40050fd2e..d4a21402f 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "prettier:ci": "prettier --list-different '**/*.{ts,tsx,json,md}' --config .prettierrc", "report_coverage": "lcov-result-merger 'packages/*/coverage/lcov.info' | coveralls", "test:installation": "node ./packages/monorepo-scripts/lib/test_installation.js", + "test:installation:local": "IS_LOCAL_PUBLISH=true node ./packages/monorepo-scripts/lib/test_installation.js", "run:publish": "run-s install:all build:monorepo_scripts script:prepublish_checks rebuild:no_website script:publish", "run:publish:local": "IS_LOCAL_PUBLISH=true yarn run:publish", "script:prepublish_checks": "node ./packages/monorepo-scripts/lib/prepublish_checks.js", diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts index a9610e5ee..12c0e7603 100644 --- a/packages/monorepo-scripts/src/test_installation.ts +++ b/packages/monorepo-scripts/src/test_installation.ts @@ -9,6 +9,8 @@ import * as rimraf from 'rimraf'; import { utils } from './utils/utils'; (async () => { + const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true'; + const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873' : 'https://registry.npmjs.org'; const monorepoRootPath = path.join(__dirname, '../../..'); const packages = utils.getTopologicallySortedPackages(monorepoRootPath); const installablePackages = _.filter( @@ -26,9 +28,9 @@ import { utils } from './utils/utils'; fs.mkdirSync(testDirectory); await execAsync('yarn init --yes', { cwd: testDirectory }); const npmrcFilePath = path.join(testDirectory, '.npmrc'); - fs.writeFileSync(npmrcFilePath, `registry=http://localhost:4873`); + fs.writeFileSync(npmrcFilePath, `registry=${registry}`); utils.log(`Installing ${packageName}@${lastChangelogVersion}`); - await execAsync(`npm install --save ${packageName}@${lastChangelogVersion} --registry=http://localhost:4873`, { + await execAsync(`npm install --save ${packageName}@${lastChangelogVersion} --registry=${registry}`, { cwd: testDirectory, }); const indexFilePath = path.join(testDirectory, 'index.ts'); -- cgit