aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts/src/utils
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-25 03:39:31 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-25 03:57:47 +0800
commitc40b3dea6cefc9a192136d66311839bd7c5d5169 (patch)
treef2bca973ab6e03afa9870ff6bdb9e0ef18c9efe8 /packages/monorepo-scripts/src/utils
parentdbc798596b052d3e28cf5772c94789d37ee5a4c7 (diff)
downloaddexon-0x-contracts-c40b3dea6cefc9a192136d66311839bd7c5d5169.tar.gz
dexon-0x-contracts-c40b3dea6cefc9a192136d66311839bd7c5d5169.tar.zst
dexon-0x-contracts-c40b3dea6cefc9a192136d66311839bd7c5d5169.zip
Specify registry url only if local publish attempted
Diffstat (limited to 'packages/monorepo-scripts/src/utils')
-rw-r--r--packages/monorepo-scripts/src/utils/configs.ts8
-rw-r--r--packages/monorepo-scripts/src/utils/npm_utils.ts6
2 files changed, 11 insertions, 3 deletions
diff --git a/packages/monorepo-scripts/src/utils/configs.ts b/packages/monorepo-scripts/src/utils/configs.ts
new file mode 100644
index 000000000..e579bdb7c
--- /dev/null
+++ b/packages/monorepo-scripts/src/utils/configs.ts
@@ -0,0 +1,8 @@
+const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true';
+const LOCAL_NPM_REGISTRY_URL = 'http://localhost:4873';
+const REMOTE_NPM_REGISTRY_URL = 'https://registry.npmjs.org';
+
+export const configs = {
+ IS_LOCAL_PUBLISH,
+ NPM_REGISTRY_URL: IS_LOCAL_PUBLISH ? LOCAL_NPM_REGISTRY_URL : REMOTE_NPM_REGISTRY_URL,
+};
diff --git a/packages/monorepo-scripts/src/utils/npm_utils.ts b/packages/monorepo-scripts/src/utils/npm_utils.ts
index 7c8310459..9c8e51508 100644
--- a/packages/monorepo-scripts/src/utils/npm_utils.ts
+++ b/packages/monorepo-scripts/src/utils/npm_utils.ts
@@ -4,14 +4,14 @@ import * as _ from 'lodash';
import { PackageRegistryJson } from '../types';
-const lernaJson = JSON.parse(fs.readFileSync('lerna.json').toString());
-const NPM_REGISTRY_BASE_URL = lernaJson.registry;
+import { configs } from './configs';
+
const SUCCESS_STATUS = 200;
const NOT_FOUND_STATUS = 404;
export const npmUtils = {
async getPackageRegistryJsonIfExistsAsync(packageName: string): Promise<PackageRegistryJson | undefined> {
- const url = `${NPM_REGISTRY_BASE_URL}/${packageName}`;
+ const url = `${configs.NPM_REGISTRY_URL}/${packageName}`;
const response = await fetch(url);
if (response.status === NOT_FOUND_STATUS) {