Moving set_env to fusebox task. Fixes #30.
This commit is contained in:
parent
5249a21479
commit
6dcc7d5d07
|
@ -11,6 +11,7 @@ const transformInferno = require('ts-transform-inferno').default;
|
||||||
const transformClasscat = require('ts-transform-classcat').default;
|
const transformClasscat = require('ts-transform-classcat').default;
|
||||||
let fuse, app;
|
let fuse, app;
|
||||||
let isProduction = false;
|
let isProduction = false;
|
||||||
|
var setEnv = require('./set_env.js').setEnv;
|
||||||
|
|
||||||
Sparky.task('config', _ => {
|
Sparky.task('config', _ => {
|
||||||
fuse = new FuseBox({
|
fuse = new FuseBox({
|
||||||
|
@ -43,13 +44,16 @@ Sparky.task('config', _ => {
|
||||||
});
|
});
|
||||||
Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/'));
|
Sparky.task('clean', _ => Sparky.src('dist/').clean('dist/'));
|
||||||
Sparky.task('env', _ => (isProduction = true));
|
Sparky.task('env', _ => (isProduction = true));
|
||||||
|
Sparky.task('set_env', _ => {
|
||||||
|
setEnv();
|
||||||
|
});
|
||||||
Sparky.task('copy-assets', () => Sparky.src('assets/*.ico').dest('dist/'));
|
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();
|
fuse.dev();
|
||||||
app.hmr().watch();
|
app.hmr().watch();
|
||||||
return fuse.run();
|
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
|
// fuse.dev({ reload: true }); // remove after demo
|
||||||
return fuse.run();
|
return fuse.run();
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
"description": "A simple UI for Torrents.csv",
|
"description": "A simple UI for Torrents.csv",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prestart": "node set_env.js",
|
|
||||||
"prebuild": "node set_env.js",
|
|
||||||
"start": "node fuse dev",
|
"start": "node fuse dev",
|
||||||
"build": "node fuse prod"
|
"build": "node fuse prod"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
require('dotenv').config();
|
require('dotenv').config();
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
|
exports.setEnv = function() {
|
||||||
if (process.env.TORRENTS_CSV_ENDPOINT) {
|
if (process.env.TORRENTS_CSV_ENDPOINT) {
|
||||||
let env_line = `export const endpoint = '${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) {
|
fs.writeFile("src/env.ts", env_line, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
}
|
}
|
||||||
console.log("Found $TORRENTS_CSV_ENDPOINT, wrote src/env.ts");
|
console.log("Found $TORRENTS_CSV_ENDPOINT, wrote src/env.ts");
|
||||||
console.log("\t" + env_line);
|
console.log("\t" + env_line);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log("No $TORRENTS_CSV_ENDPOINT environment variable set, using http://0.0.0.0:8080");
|
console.log("No $TORRENTS_CSV_ENDPOINT environment variable set, using http://0.0.0.0:8080");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue