-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·49 lines (39 loc) · 950 Bytes
/
index.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
#!/usr/bin/env node
'use strict';
const spawn = require('child_process').spawn;
const tmp = require('tmp');
const fs = require('fs');
var yellMe = process.argv[2];
var domain = process.argv[3];
if(yellMe == null){
return console.log("hey you have to yell something..");
}
var html = `
<!DOCTYPE html>
<html>
<head>
<title>${yellMe}</title>
<style>
p{
font-size: ${Math.max(100/yellMe.length, 20)}vw;
word-wrap: break-word;
}
</style>
</head>
<body>
<p>${yellMe}</p>
</body>
</html>
`
const tmpdir = tmp.dirSync();
const tmpobj = tmp.fileSync({ dir: tmpdir.name, name: 'index.html' });
fs.writeFile(tmpobj.name, html, function (err) {
if (err) return console.log(err);
var surgeArgs = [ tmpdir.name ];
if(domain) surgeArgs.push(domain);
const child = spawn( 'surge', surgeArgs);
child.stdin.setEncoding('utf-8');
child.stdout.pipe(process.stdout);
child.stdin.write("\n");
child.stdin.end();
})