-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
89 lines (79 loc) · 2.5 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
80
81
82
83
84
85
86
87
88
89
const gulp = require('gulp');
const shell = require('gulp-shell');
const express = require('express');
const mocha = require('gulp-mocha');
const fs = require("fs");
const ts = require("gulp-typescript");
const tsProject = ts.createProject("tsconfig.json");
const PORT = 8000;
gulp.task('compile-wasm', () => {
return gulp.src('./src/wast/*.wat', {read: false})
.pipe(shell([
'node compile_matmach_wasm.js <%= file.path %> -b'
]))
});
gulp.task('compile-browser', () => {
return gulp.src('./src/*.wat', {read: false})
.pipe(shell([
'./run_wasm_browser.sh <%= file.path %>'
]))
});
gulp.task("compile",["compile-wasm","compile-ts"]);
gulp.task('compile-watch',()=>{
gulp.watch(['./src/ts/**/**/*.ts',"./src/wast/*.wat"],["compile"]);
});
gulp.task("test-ts",["compile-ts"],()=>{
if(fs.existsSync('./bin/matmachjs.wasm')){
return gulp.src('./test/node/**/**/*.test.ts',
{read: false}).pipe(mocha(
{require:["ts-node/register"],timeout:5000}));
}
});
gulp.task("test",["test-js","test-ts"]);
gulp.task("test-js",["compile-wasm"],()=>{
if(fs.existsSync('./bin/matmachjs.wasm')){
return gulp.src('./test/node/**/*.test.js', {read: false})
.pipe(mocha());
}
});
gulp.task("test-watch",()=>{
gulp.watch(['./test/**/**/*.test.js','./src/**/*.wat','./src/ts/**/**/*.ts'],["test"])
});
gulp.task('watch-compile-wasm',()=>{
return gulp.watch(['./src/wast/*.wat'],['compile-wasm']);
});
gulp.task('watch-compile-ts',()=>{
return gulp.watch(['./src/ts/**/**/*.ts'],['compile-ts']);
});
gulp.task('default',()=>{
return gulp.watch(['./src/wast/*/wat','src/ts/**/**/*.ts'],['compile-wasm','compile-ts']);
});
gulp.task('browser',()=>{
startServer(PORT,()=>
{
console.log("Server started at 8000!");
return gulp.watch('*.wat',['compile-browser']);
});
});
gulp.task("compile-ts", function () {
return tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest("bin"));
});
gulp.task('haider',()=>{
return gulp.watch('/usr/local/bin/russian_doll.py',['read_py'])
});
gulp.task('read_py',()=>{
return gulp.src('/usr/local/bin/russian_doll.py').pipe(gulp.dest("./hello.py"))
});
function startServer(port, callback){
const app = express();
express.static.mime.types['wasm'] = 'application/wasm';
app.use(express.static('./test/browser/'));
app.get('/result',(req, res)=>{
console.log(String(req.query.timing).bgGreen.white);
res.send("Done!");
// process.exit(0);
});
app.listen(port, callback);
}