Skip to content

Instantly share code, notes, and snippets.

@uxter
Created August 28, 2017 14:32
Show Gist options
  • Save uxter/6b46029ae014305b62e7a697c1fae11a to your computer and use it in GitHub Desktop.
Save uxter/6b46029ae014305b62e7a697c1fae11a to your computer and use it in GitHub Desktop.
Mini CI
#!/bin/bash
URL="http://127.0.0.1:23813"
SRC="sources"
DST="sources.zip"
# OPTS: SRC DST
OPTS="-r $DST $SRC"
# OPTS: EXCLUDE
OPTS="$OPTS -x *node_modules*"
OPTS="$OPTS -x *.git*"
OPTS="$OPTS -x *.idea*"
# MAKE ZIP
zip $OPTS
# UPLOAD ZIP
curl -F "src=@$(pwd)/$DST" $URL
# REMOVE ZIP
rm $DST
const fs = require('fs');
const http = require('http');
const formidable = require('formidable');
const unzip = require('unzip');
const fstream = require('fstream');
http.createServer(function (req, res) {
fs.rmdir('src', function() {
fs.mkdir('src', function() {
var form = new formidable.IncomingForm();
form.parse(req, function (err, fields, files) {
var readStream = fs.createReadStream(files.src.path);
var writeStream = fstream.Writer('src');
readStream
.pipe(unzip.Parse())
.pipe(writeStream)
.on('end', function() {
res.write('File uploaded\n');
res.end();
});
});
});
});
}).listen(23813);
{
"name": "mini-ci",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"formidable": "^1.1.1",
"fstream": "^1.0.11",
"unzip": "^0.1.11"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment