-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (52 loc) · 1.62 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
/// <binding />
'use strict';
const gulp = require('gulp');
const gutil = require('gulp-util');
const tsproject = require('tsproject');
const clean = require('gulp-clean');
const runSequence = require('run-sequence');
const https = require('https');
const fs = require('fs');
const config = require('./config.json');
gulp.task('clean', () => {
return gulp.src('dist', { read: false })
.pipe(clean());
});
gulp.task('compile', () => {
return tsproject.src('./tsconfig.json', {
}).pipe(gulp.dest('dist'));
});
gulp.task('upload', ['compile'], () => {
let configName = process.env.NODE_ENV;
let isDebug = configName === "Debug";
gutil.log("Configuration: " + configName);
let screeps = {
email: config.email,
password: config.password,
data: {
branch: isDebug ? config.branch_debug : config.branch_release,
modules: {
main: fs.readFileSync('./dist/main.js', { encoding: "utf8" })
}
}
};
let req = https.request({
hostname: 'screeps.com',
port: 443,
path: '/api/user/code',
method: 'POST',
auth: screeps.email + ':' + screeps.password,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
}, (res) => {
gutil.log('Build ' + gutil.colors.cyan('completed') + ' with HTTPS response ' + gutil.colors.magenta(res.statusCode));
});
req.write(JSON.stringify(screeps.data));
req.end();
});
//gulp.task('watch', () => {
// gulp.watch('./src/**/*.ts');
//});
//gulp.task('build', ['upload']);
gulp.task('default', ['upload']);