-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.js
47 lines (40 loc) · 1.21 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
"use strict";
var gulp = require('gulp');
var webpack = require('gulp-webpack');
var tsproject = require('tsproject');
var https = require('https');
var fs = require('fs');
var secrets = require('./secrets.js');
gulp.task('compile', function () {
return gulp.src('./src/')
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('./dist/'))
});
gulp.task('upload-sim', ['compile'], function () {
console.log("Starting upload");
var email = secrets.email,
password = secrets.password,
data = {
branch: 'default',
modules: { main: fs.readFileSync('./dist/screeps.js', { encoding: "utf8" }) }
};
var req = https.request({
hostname: 'screeps.com',
port: 443,
path: '/api/user/code',
method: 'POST',
auth: email + ':' + password,
headers: {
'Content-Type': 'application/json; charset=utf-8'
}
}, function (res) {
console.log("Response: " + res.statusCode);
});
req.write(JSON.stringify(data));
req.end();
});
gulp.task('watch', function () {
gulp.watch('./src/**/*.ts', ['build']);
});
gulp.task('build', ['upload-sim']);
gulp.task('default', ['watch']);