Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Windows interop #624

Merged
merged 8 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
environment:
matrix:
- nodejs_version: "6"
- nodejs_version: "8"

# cache:
# - node_modules

platform:
- x64

install:
- ps: Install-Product node $env:nodejs_version $env:platform
- node --version
- npm --version
- npm install

test_script:
- npm test

build: off

version: "{build}"
2 changes: 2 additions & 0 deletions src/utils/get-files-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function loadPaths (opts, file) {
}

if (stats.isDirectory() && opts.recursive) {
// glob requires a POSIX filename
file = file.split(path.sep).join('/')
const globEscapedDir = escape(file) + (file.endsWith('/') ? '' : '/')
const mg = new glob.sync.GlobSync(`${globEscapedDir}` + '**/*', {
follow: followSymlinks,
Expand Down
10 changes: 9 additions & 1 deletion src/utils/request-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,15 @@ function onRes (buffer, cb) {
res.on('end', () => {
let err = res.trailers['x-stream-error']
if (err) {
err = JSON.parse(err)
// Not all errors are JSON
try {
err = JSON.parse(err)
} catch (e) {
err = {
Code: 'n/a',
Message: err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

const error = new Error(`Server responded with 500`)
error.code = err.Code
error.message = err.Message
Expand Down
6 changes: 6 additions & 0 deletions test/diag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const os = require('os')

describe('.diag', function () {
this.timeout(50 * 1000)

if (os.platform() === 'win32') {
it('skip these on Windows')
return
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

let ipfs
let fc

Expand Down
1 change: 1 addition & 0 deletions test/ipfs-factory/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function Factory () {
spawnNode()
} else {
ioC = io.connect(sioUrl, sioOptions)
ioC.once('error', callback)
ioC.once('connect_error', callback)
ioC.once('connect', () => {
sioConnected = true
Expand Down
5 changes: 3 additions & 2 deletions test/ipfs-factory/server-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const DaemonSpawner = require('./daemon-spawner')
module.exports = (http) => {
const io = new SocketIO(http.listener)
io.on('connection', handle)
io.on('error', (err) => this.emit('error', err))

const ds = new DaemonSpawner()

Expand All @@ -17,7 +18,7 @@ module.exports = (http) => {
function spawnNode (repoPath, config) {
ds.spawnNode(repoPath, config, (err, apiAddr) => {
if (err) {
throw err
return this.emit('error', err)
}
this.emit('fc-node', apiAddr.toString())
})
Expand All @@ -26,7 +27,7 @@ module.exports = (http) => {
function dismantle () {
ds.dismantle((err) => {
if (err) {
throw err
return this.emit('error', err)
}
this.emit('fc-nodes-shutdown')
})
Expand Down
7 changes: 3 additions & 4 deletions test/request-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ describe('\'deal with HTTP weirdness\' tests', () => {
})

describe('trailer headers', () => {
it('should deal with trailer x-stream-error correctly', (done) => {
if (!isNode) {
return done()
}
// TODO: needs fixing https://github.com/ipfs/js-ipfs-api/pull/624#issuecomment-344181950
it.skip('should deal with trailer x-stream-error correctly', (done) => {
if (!isNode) { return done() }

const server = require('http').createServer((req, res) => {
const resStream = pump(res, ndjson.stringify())
Expand Down