fix(build): Ensure env for build
parent
5b7b3ca33c
commit
9224613a74
|
@ -40,7 +40,7 @@
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gatsby build",
|
"build": "node ../config/ensure-env.js && gatsby build",
|
||||||
"develop": "gatsby develop",
|
"develop": "gatsby develop",
|
||||||
"format": "prettier --write '**/*.js'",
|
"format": "prettier --write '**/*.js'",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
|
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const env = require('./env');
|
const env = require('./env');
|
||||||
|
|
||||||
fs.access('./api-server/server/rev-manifest.json', function(err) {
|
const apiPath = path.resolve(__dirname, '../api-server');
|
||||||
|
const clientPath = path.resolve(__dirname, '../client');
|
||||||
|
|
||||||
|
fs.access(`${apiPath}/server/rev-manifest.json`, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('\n\ncreating manifest\n\n');
|
console.log('\n\ncreating manifest\n\n');
|
||||||
return fs.writeFileSync('./api-server/server/rev-manifest.json', '{}');
|
return fs.writeFileSync('./api-server/server/rev-manifest.json', '{}');
|
||||||
|
@ -13,7 +17,7 @@ fs.access('./api-server/server/rev-manifest.json', function(err) {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.access('./api-server/server/resources/pathMigration.json', err => {
|
fs.access(`${apiPath}/server/resources/pathMigration.json`, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('\n\ncreating pathMigration\n\n');
|
console.log('\n\ncreating pathMigration\n\n');
|
||||||
return fs.writeFileSync(
|
return fs.writeFileSync(
|
||||||
|
@ -25,6 +29,6 @@ fs.access('./api-server/server/resources/pathMigration.json', err => {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.ensureDir('./client/config/').then(() =>
|
fs.ensureDir(`${clientPath}/config/`).then(() =>
|
||||||
fs.writeFileSync('./client/config/env.json', JSON.stringify(env))
|
fs.writeFileSync(`${clientPath}/config/env.json`, JSON.stringify(env))
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue