-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
79 lines (69 loc) · 3.09 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var path = require('path');
var gulp = require('gulp');
var sass = require('gulp-sass');
var concat = require('gulp-concat');
var cleanCSS = require('gulp-clean-css');
var rename = require('gulp-rename');
var spawn = require('child_process').spawn;
var node, env = process.env;
// --------------------- Build CSS --------------------- //
gulp.task('build-sass', function () {
gulp.src(path.join(__dirname, '/scss/*.scss'))
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(path.join(__dirname, '/scss/temp'))) //build them here first
.pipe(concat('main.css')) //concat them all
//.pipe(gulp.dest(path.join(__dirname, '/public/css')))
.pipe(cleanCSS()) //minify
.pipe(rename('main.min.css'))
.pipe(gulp.dest(path.join(__dirname, '/public/css'))); //dump it here
});
// -------------------- Run Marbles -------------------- //
gulp.task('server', function (a, b) {
if (node) node.kill();
node = spawn('node', ['app.js'], { env: env, stdio: 'inherit' }); //command, file, options
});
// -------------- Watch for File Changes --------------- //
gulp.task('watch-sass', ['build-sass'], function () {
gulp.watch(path.join(__dirname, '/scss/*.scss'), ['build-sass']);
});
gulp.task('watch-server', function () {
gulp.watch(path.join(__dirname, '/routes/**/*.js'), ['server']);
gulp.watch([path.join(__dirname, '/utils/fc_wrangler/*.js')], ['server']);
gulp.watch([path.join(__dirname, '/utils/*.js')], ['server']);
gulp.watch(path.join(__dirname, '/app.js'), ['server']);
});
// ---------------- Runnable Gulp Tasks ---------------- //
gulp.task('default', ['watch-sass', 'watch-server', 'server']);
gulp.task('marbles_tls', ['env_tls', 'watch-sass', 'watch-server', 'server']); //run with command `gulp marbles_tls` for IBM Cloud blockchain service
gulp.task('marbles_local', ['env_local', 'watch-sass', 'watch-server', 'server']); //run with command `gulp marbles_local` for a local network
gulp.task('marbles_cs', ['env_cs', 'watch-sass', 'watch-server', 'server']); //run with command `gulp marbles_cs` for IBM Cloud container service
gulp.task('marbles_dev', ['env_dev', 'watch-sass', 'watch-server', 'server']); //run with command `gulp marbles_dev` if you are me
gulp.task('marbles_dev2', ['env_dev2', 'watch-sass', 'watch-server', 'server']); //run with command `gulp marbles_dev` if you are me
gulp.task('build', ['watch-sass']);
// IBM Cloud Blockchain Service
gulp.task('env_tls', function () {
env['creds_filename'] = 'marbles_tls.json';
});
// Local Fabric via Docker Compose
gulp.task('env_local', function () {
env['creds_filename'] = 'marbles_local.json';
});
// IBM Cloud Container Service
gulp.task('env_cs', function () {
env['creds_filename'] = 'marbles_cs.json';
});
// Dev
gulp.task('env_dev', function () {
env['creds_filename'] = 'marbles_dev.json';
/*
env.CHAINCODE_ID = 'marbles-v8';
env.CHAINCODE_VERSION = '1521498413';
env.MSP_ID = 'org2';
const CONNECTION_PROFILE = require('./config/temp.json');
env.CONNECTION_PROFILE = JSON.stringify(CONNECTION_PROFILE);
*/
});
// Dev 2
gulp.task('env_dev2', function () {
env['creds_filename'] = 'marbles_dev2.json';
});