0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/test/functional/lib/startup.js
Alex Kocharin 6a778e8c17 change code style to jshttp
close #155, see reasons there

This is a huge commit, so let me know if it will cause
any trouble, I might consider reverting it if it's the case.
2014-11-12 17:37:43 +03:00

43 lines
1.1 KiB
JavaScript

var assert = require('assert')
var fork = require('child_process').fork
var express = require('express')
var readfile = require('fs').readFileSync
var rimraf = require('rimraf')
var Server = require('./server')
var forks = process.forks = []
process.server = Server('http://localhost:55551/')
process.server2 = Server('http://localhost:55552/')
process.express = express()
process.express.listen(55550)
module.exports.start = function start(dir, conf, cb) {
rimraf(__dirname + '/../' + dir, function() {
// filter out --debug-brk
var oldArgv = process.execArgv
process.execArgv = process.execArgv.filter(function(x) {
return x !== '--debug-brk'
})
var f = fork(__dirname + '/../../../bin/sinopia'
, ['-c', __dirname + '/../' + conf]
, {silent: !process.env.TRAVIS}
)
forks.push(f)
f.on('message', function(msg) {
if ('sinopia_started' in msg) {
cb(), cb = function(){}
}
})
f.on('error', function(err) {
throw err
})
process.execArgv = oldArgv
})
}
process.on('exit', function() {
if (forks[0]) forks[0].kill()
if (forks[1]) forks[1].kill()
})