Moving set_env to fusebox task. Fixes #30.

This commit is contained in:
Dessalines 2018-12-25 15:19:16 -08:00
parent 5249a21479
commit 6dcc7d5d07
3 changed files with 19 additions and 17 deletions

View File

@ -11,6 +11,7 @@ const transformInferno = require('ts-transform-inferno').default;
const transformClasscat = require('ts-transform-classcat').default;
let fuse, app;
let isProduction = false;
var setEnv = require('./set_env.js').setEnv;
Sparky.task('config', _ => {
fuse = new FuseBox({
@ -43,13 +44,16 @@ Sparky.task('config', _ => {
});
Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/'));
Sparky.task('env', _ => (isProduction = true));
Sparky.task('set_env', _ => {
setEnv();
});
Sparky.task('copy-assets', () => Sparky.src('assets/*.ico').dest('dist/'));
Sparky.task('dev', ['clean', 'config', 'copy-assets'], _ => {
Sparky.task('dev', ['clean', 'set_env', 'config', 'copy-assets'], _ => {
fuse.dev();
app.hmr().watch();
return fuse.run();
});
Sparky.task('prod', ['clean', 'env', 'config', 'copy-assets'], _ => {
Sparky.task('prod', ['clean', 'set_env', 'env', 'config', 'copy-assets'], _ => {
// fuse.dev({ reload: true }); // remove after demo
return fuse.run();
});

View File

@ -4,8 +4,6 @@
"description": "A simple UI for Torrents.csv",
"main": "index.js",
"scripts": {
"prestart": "node set_env.js",
"prebuild": "node set_env.js",
"start": "node fuse dev",
"build": "node fuse prod"
},

View File

@ -1,17 +1,17 @@
require('dotenv').config();
const fs = require('fs');
if (process.env.TORRENTS_CSV_ENDPOINT) {
let env_line = `export const endpoint = '${process.env.TORRENTS_CSV_ENDPOINT}';`;
fs.writeFile("src/env.ts", env_line, function (err) {
if (err) {
return console.log(err);
}
console.log("Found $TORRENTS_CSV_ENDPOINT, wrote src/env.ts");
console.log("\t" + env_line);
});
} else {
console.log("No $TORRENTS_CSV_ENDPOINT environment variable set, using http://0.0.0.0:8080");
exports.setEnv = function() {
if (process.env.TORRENTS_CSV_ENDPOINT) {
let env_line = `export const endpoint = '${process.env.TORRENTS_CSV_ENDPOINT}';`;
fs.writeFile("src/env.ts", env_line, function (err) {
if (err) {
return console.log(err);
}
console.log("Found $TORRENTS_CSV_ENDPOINT, wrote src/env.ts");
console.log("\t" + env_line);
});
} else {
console.log("No $TORRENTS_CSV_ENDPOINT environment variable set, using http://0.0.0.0:8080");
}
}