 
 NEFT_BIN_PATH = pathUtils.join(fs.realpathSync('./'), 'bin/neft.js')
 
+forkSilent = (path, args, options, callback) ->
+    options = utils.mergeAll {}, options, silent: true
+    child = cp.fork path, args, options
+    stdout = ''
+    child.stdout.on 'data', (data) -> stdout += data
+    stderr = ''
+    child.stderr.on 'data', (data) -> stderr += data
+    child.on 'exit', (code) ->
+        callback code, stdout, stderr
+    child
+
 createApp = (callback) ->
     path = pathUtils.join os.tmpdir(), 'neft-project'
     fs.removeSync path
-
-    cpCmd = "#{NEFT_BIN_PATH} create #{path}"
-    cp.exec cpCmd, callback
+    forkSilent NEFT_BIN_PATH, ['create', path], null, callback
     path
 
 describe 'CLI', ->

        describe 'node', ->
            it 'starts node server', (done) ->
                path = createApp (err, _, stderr) ->
                    child = cp.exec "cd #{path} && #{NEFT_BIN_PATH} run node", (err, _, stderr) ->
                        done err or stderr

                    child.stdout.on 'data', (msg) ->
                        if utils.has(msg, 'Start as')
                            child.kill()
                            setTimeout done

        describe 'node', ->
            it 'creates bundle', (done) ->
                path = createApp (err, _, stderr) ->
                    forkSilent NEFT_BIN_PATH, ['build', 'node'], cwd: path, (err, _, stderr) ->
                        assert.ok fs.existsSync pathUtils.join(path, 'build/app-node-develop.js')
                        done err or stderr

        describe 'browser', ->
            it 'creates bundle', (done) ->
                path = createApp (err, _, stderr) ->
                    forkSilent NEFT_BIN_PATH, ['build', 'browser'], cwd: path, (err, _, stderr) ->
                        assert.ok fs.existsSync pathUtils.join(path, 'build/app-browser-develop.js')
                        done err or stderr

