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

Commit

Permalink
fix: Windows support (#7)
Browse files Browse the repository at this point in the history
* fix: Windows support

* chore: update CI and deps

* another circle

* chore(package): dev dependencies closes #6

* chore: standard coding style

* chore: fix lint errors

* Revert "chore: fix lint errors"

This reverts commit 71a9536.

* chore: more lint issues
  • Loading branch information
daviddias authored Nov 4, 2017
1 parent 1507a6b commit e7c8f25
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 50 deletions.
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
- npm install

test_script:
- node --version
- npm --version
- npm test

build: off

version: "{build}"
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@ language: node_js

matrix:
include:
- node_js: 4
env: CXX=g++-4.8
- node_js: 6
env:
- SAUCE=true
- CXX=g++-4.8
- node_js: stable
env: CXX=g++-4.8
- node_js: 8
env: CXX=g++-4.8
# - node_js: stable
# env: CXX=g++-4.8

script:
- npm run lint
- npm run flow
- npm test
- npm run test
- npm run coverage
- make test

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start

after_success:
- npm run coverage-publish

addons:
firefox: 'latest'
apt:
Expand Down
12 changes: 9 additions & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ machine:
node:
version: stable

test:
post:
- npm run coverage -- --upload

dependencies:
pre:
- google-chrome --version
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
- sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome.deb || true
- sudo apt-get update
- sudo apt-get --only-upgrade install google-chrome-stable
- sudo apt-get install -f
- sudo apt-get install --only-upgrade lsb-base
- sudo dpkg -i google-chrome.deb
- google-chrome --version
44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"description": "Datastore implementation with file system backend",
"main": "src/index.js",
"scripts": {
"lint": "aegir-lint",
"test": "aegir-test --env node",
"lint": "aegir lint",
"test": "aegir test --target node",
"flow": "flow",
"release": "aegir-release --env node --docs",
"release-minor": "aegir-release --type minor --env node --docs",
"release-major": "aegir-release --type major --env node --docs",
"coverage": "aegir-coverage",
"coverage-publish": "aegir-coverage publish",
"docs": "aegir-docs"
"release": "aegir release --target node --docs",
"release-minor": "aegir release --type minor --target node --docs",
"release-major": "aegir release --type major --target node --docs",
"coverage": "aegir coverage",
"coverage-publish": "aegir coverage --provider coveralls",
"docs": "aegir docs"
},
"repository": {
"type": "git",
Expand All @@ -32,27 +32,27 @@
},
"homepage": "https://github.com/ipfs/js-datastore-fs#readme",
"dependencies": {
"datastore-core": "^0.3.0",
"datastore-core": "github:ipfs/js-datastore-core#windows-interop",
"glob": "^7.1.2",
"graceful-fs": "^4.1.11",
"interface-datastore": "^0.3.0",
"level-js": "^2.2.4",
"leveldown": "^1.7.2",
"levelup": "^1.3.8",
"interface-datastore": "^0.4.0",
"mkdirp": "^0.5.1",
"pull-glob": "^1.0.6",
"pull-stream": "^3.6.0",
"write-file-atomic": "^2.1.0"
"pull-stream": "^3.6.1",
"write-file-atomic": "^2.3.0"
},
"devDependencies": {
"aegir": "^11.0.2",
"aegir": "^12.1.3",
"async": "^2.5.0",
"chai": "^4.1.0",
"cids": "^0.5.1",
"chai": "^4.1.2",
"cids": "~0.5.2",
"dirty-chai": "^2.0.1",
"flow-bin": "^0.51.0",
"flow-bin": "^0.58.0",
"flow-typed": "^2.2.3",
"memdown": "^1.2.4",
"rimraf": "^2.6.1"
"level-js": "^2.2.4",
"leveldown": "^2.0.0",
"levelup": "^2.0.0",
"memdown": "^1.4.1",
"rimraf": "^2.6.2"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
Expand Down
29 changes: 15 additions & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const fs = require('graceful-fs')
const pull = require('pull-stream')
const glob = require('pull-glob')
const glob = require('glob')
const setImmediate = require('async/setImmediate')
const waterfall = require('async/series')
const each = require('async/each')
Expand Down Expand Up @@ -136,7 +136,11 @@ class FsDatastore {
throw new Error(`Invalid extension: ${path.extname(file)}`)
}

return new Key(file.slice(this.path.length, -ext.length))
const keyname = file
.slice(this.path.length, -ext.length)
.split(path.sep)
.join('/')
return new Key(keyname)
}

/**
Expand Down Expand Up @@ -259,7 +263,13 @@ class FsDatastore {
* @returns {PullStream}
*/
query (q /* : Query<Buffer> */) /* : QueryResult<Buffer> */ {
let tasks = [glob(path.join(this.path, '**', '*' + this.opts.extension))]
// glob expects a POSIX path
let prefix = q.prefix || '**'
let pattern = path
.join(this.path, prefix, '*' + this.opts.extension)
.split(path.sep)
.join('/')
let tasks = [pull.values(glob.sync(pattern))]

if (!q.keysOnly) {
tasks.push(pull.asyncMap((f, cb) => {
Expand All @@ -277,21 +287,12 @@ class FsDatastore {
tasks.push(pull.map(f => ({ key: this._decode(f) })))
}

let filters = []

if (q.prefix != null) {
const prefix = q.prefix
filters.push((e, cb) => cb(null, e.key.toString().startsWith(prefix)))
}

if (q.filters != null) {
filters = filters.concat(q.filters)
tasks = tasks.concat(q.filters.map(asyncFilter))
}

tasks = tasks.concat(filters.map(f => asyncFilter(f)))

if (q.orders != null) {
tasks = tasks.concat(q.orders.map(o => asyncSort(o)))
tasks = tasks.concat(q.orders.map(asyncSort))
}

if (q.offset != null) {
Expand Down
5 changes: 2 additions & 3 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe('FsDatastore', () => {
})

it('query', (done) => {
const fs = new FsStore(path.join(__dirname, 'test-repo/blocks'))
const fs = new FsStore(path.join(__dirname, 'test-repo', 'blocks'))

pull(
fs.query({}),
Expand Down Expand Up @@ -140,8 +140,7 @@ describe('FsDatastore', () => {
})
})

// TODO: depends on sharding query fix
describe.skip('interface-datastore (sharding(fs))', () => {
describe('interface-datastore (sharding(fs))', () => {
const dir = utils.tmpdir()

require('interface-datastore/src/tests')({
Expand Down

0 comments on commit e7c8f25

Please sign in to comment.