You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

54 lines
1.3 KiB

import path from 'path';
/**
* Since this file overwrites environment variables for `config` lib,
* it's important to "import" this file before all scripts in entry point file,
* especially before `config` module import.
*/
/**
* Export constant variables
*/
export const PRODUCTION_REGISTRY_URL = 'https://blocks-registery.axe-web.com';
export const IS_DEV = process.env.NODE_ENV === 'development';
export const BLOCK_NAME = process.env.BLOCK_NAME;
export const MODULE_PATH = getModulePath();
export const PROJECT_PATH = getProjectPath();
/**
* Overwrite env variables.
*/
process.env.NODE_CONFIG_DIR = path.join(PROJECT_PATH, 'config');
/**
* Private functions.
* Don't export these, export constants.
*/
function getModulePath() {
let modulePath = 'node_modules/block-dev-tool';
if (typeof process.env.MODULE_PATH !== 'undefined') {
modulePath = process.env.MODULE_PATH;
} else if (BLOCK_NAME) {
modulePath = 'node_modules/@axe-web/block-dev-tool';
}
return modulePath;
}
function getProjectPath() {
let projectPath = '';
if (typeof process.env.PROJECT_PATH !== 'undefined') {
projectPath = path.join(process.env.PROJECT_PATH, BLOCK_NAME)
} else if (BLOCK_NAME) {
projectPath = path.join('blocks', BLOCK_NAME)
}
return projectPath;
}