Browse Source
Reviewed-on: https://git.devdevdev.life/AXE-WEB/block-dev-tool/pulls/7test-gpt-generated
8 changed files with 96 additions and 40 deletions
@ -0,0 +1,46 @@ |
|||
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; |
|||
|
|||
/** |
|||
* Overwrite env variables. |
|||
*/ |
|||
|
|||
process.env.NODE_CONFIG_DIR = path.join(getProjectPath(), 'config'); |
|||
|
|||
|
|||
export function getModulePath() { |
|||
let modulePath = 'node_modules/block-dev-tool'; |
|||
|
|||
if (typeof process.env.MODULE_PATH !== 'undefined') { |
|||
modulePath = process.env.MODULE_PATH; |
|||
} else if (process.env.BLOCK_NAME) { |
|||
modulePath = 'node_modules/@axe-web/block-dev-tool'; |
|||
} |
|||
|
|||
return modulePath; |
|||
} |
|||
|
|||
export function getProjectPath() { |
|||
let projectPath = ''; |
|||
|
|||
if (typeof process.env.PROJECT_PATH !== 'undefined') { |
|||
projectPath = path.join(process.env.PROJECT_PATH ?? '', process.env.BLOCK_NAME ?? '') |
|||
} else if (process.env.BLOCK_NAME) { |
|||
projectPath = path.join('blocks', process.env.BLOCK_NAME ?? '') |
|||
} |
|||
|
|||
return projectPath; |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
/** |
|||
* FUTURE TESTS. |
|||
* |
|||
* # ENV |
|||
* In `blocks-builder` service, we update MODULE_PATH and PROJECT_PATH environment variables before we run platform |
|||
* bundle build process. Actually before we call buildExportFiles(). |
|||
* |
|||
* We have to make sure that this logic is working properly and stable. |
|||
* |
|||
*/ |
|||
Loading…
Reference in new issue