-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (34 loc) · 1.12 KB
/
server.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
'use strict';
var path = require('path'),
http = require('http'),
express = require('express'),
brackets = require('brackets'),
app = express(),
server = http.createServer(app),
bracketsOpts = {
port: 3000,
httpRoot: '/brackets',
projectsDir: path.join(__dirname, '../', '/projects'),
supportDir: path.join(__dirname, '.', '/.brackets'),
allowUserDomains: true
};
(function() {
var childProcess = require("child_process"),
oldSpawn = childProcess.spawn;
function mySpawn() {
if(arguments[0] === '/usr/local/bin/git'){
arguments[2] = {
cwd:arguments[2].cwd
.replace(/\\/g, '/')
.replace(/^\/projects/,'../projects')
.replace(/^\/support/,'.brackets')
};
}
var result = oldSpawn.apply(null, arguments);
return result;
}
childProcess.spawn = mySpawn;
})();
brackets(server, bracketsOpts);
server.listen(bracketsOpts.port);
console.log('You can access Brackets on http://localhost:' + bracketsOpts.port + bracketsOpts.httpRoot);