Browse Source

- Make sure we can overwrite MODULE_PATH and PROJECT_PATH.

- Simplify the process of env variables setup. Provide default values.
- Include env.js in package.json
Organized all env in env.js file. It allows us to overwrite these values.
pull/7/head
Roman Axelrod 3 years ago
parent
commit
b43a4d6b4f
  1. 5
      env.js
  2. 4
      helpers.js

5
env.js

@ -13,7 +13,6 @@ import path from 'path';
export const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com'; export const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com';
export const IS_DEV = process.env.NODE_ENV === 'development'; export const IS_DEV = process.env.NODE_ENV === 'development';
export const BLOCK_NAME = process.env.BLOCK_NAME; export const BLOCK_NAME = process.env.BLOCK_NAME;
export const MODULE_PATH = getModulePath();
/** /**
* Overwrite env variables. * Overwrite env variables.
@ -27,12 +26,12 @@ process.env.NODE_CONFIG_DIR = path.join(getProjectPath(), 'config');
* Don't export these, export constants. * Don't export these, export constants.
*/ */
function getModulePath() { export function getModulePath() {
let modulePath = 'node_modules/block-dev-tool'; let modulePath = 'node_modules/block-dev-tool';
if (typeof process.env.MODULE_PATH !== 'undefined') { if (typeof process.env.MODULE_PATH !== 'undefined') {
modulePath = process.env.MODULE_PATH; modulePath = process.env.MODULE_PATH;
} else if (BLOCK_NAME) { } else if (process.env.BLOCK_NAME) {
modulePath = 'node_modules/@axe-web/block-dev-tool'; modulePath = 'node_modules/@axe-web/block-dev-tool';
} }

4
helpers.js

@ -1,5 +1,5 @@
import path from 'path'; import path from 'path';
import {BLOCK_NAME, getProjectPath, IS_DEV, MODULE_PATH} from "./env.js"; import {BLOCK_NAME, getModulePath, getProjectPath, IS_DEV} from "./env.js";
import config from 'config'; import config from 'config';
import {fileURLToPath} from 'url'; import {fileURLToPath} from 'url';
import memFs from 'mem-fs'; import memFs from 'mem-fs';
@ -17,7 +17,7 @@ export function getConfigs() {
return { return {
isDev: IS_DEV, isDev: IS_DEV,
developmentBlockName: BLOCK_NAME, developmentBlockName: BLOCK_NAME,
modulesPath: MODULE_PATH, modulesPath: getModulePath(),
projectPath: getProjectPath(), projectPath: getProjectPath(),
}; };
} }

Loading…
Cancel
Save