Skip to content

Commit

Permalink
build: use barnard59-env indirectly
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Oct 30, 2023
1 parent 0bce389 commit 5cbbb0f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
3 changes: 1 addition & 2 deletions packages/validate-shacl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
"dependencies": {
"@rdfjs/fetch": "^3.0.0",
"is-stream": "^3.0.0",
"@zazuko/env": "^1.9.0",
"readable-stream": "3 - 4",
"rdf-validate-shacl": "^0.5.1"
},
"devDependencies": {
"@rdfjs/to-ntriples": "^2.0.0",
"@zazuko/env-node": "^1.0.0",
"barnard59-env": "^0.0.0",
"assert-throws-async": "^3.0.0",
"chai": "^4.3.4",
"get-stream": "^8.0.1",
Expand Down
10 changes: 6 additions & 4 deletions packages/validate-shacl/test/validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ import assertThrows from 'assert-throws-async'
import { expect } from 'chai'
import getStream, { getStreamAsArray } from 'get-stream'
import { isReadableStream, isWritableStream } from 'is-stream'
import rdf from '@zazuko/env-node'
import toStream from 'rdf-dataset-ext/toStream.js'
import sinon from 'sinon'
import { shacl } from '../validate.js'
import env from 'barnard59-env'
import { shacl as unbound } from '../validate.js'

const shapePath = 'support/simple.shape.ttl'
new URL(shapePath, import.meta.url).toString()

const shacl = unbound.bind({ env })

async function getRDFDataset(filePath) {
return rdf.dataset().import(getRDFStream(filePath))
return env.dataset().import(getRDFStream(filePath))
}

function getRDFStream(filePath) {
return rdf.fromFile(url.fileURLToPath(new URL(filePath, import.meta.url)))
return env.fromFile(url.fileURLToPath(new URL(filePath, import.meta.url)))
}

describe('validate-shacl', () => {
Expand Down
5 changes: 2 additions & 3 deletions packages/validate-shacl/validate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { isStream, isReadableStream } from 'is-stream'
import rdf from '@zazuko/env'
import SHACLValidator from 'rdf-validate-shacl'
import { Transform } from 'readable-stream'
import { ValidationError } from './lib/errors.js'
Expand All @@ -12,7 +11,7 @@ class ValidateChunk extends Transform {
})
this.context = context
this.onViolation = onViolation
this.validator = new SHACLValidator(shape, { maxErrors, factory: rdf })
this.validator = new SHACLValidator(shape, { maxErrors, factory: context.env })
}

_transform(data, encoding, callback) {
Expand Down Expand Up @@ -52,5 +51,5 @@ export async function shacl(arg) {
throw new Error(`${shape} is not a readable stream`)
}

return new ValidateChunk(this, await rdf.dataset().import(shape), { ...options, maxErrors })
return new ValidateChunk(this, await this.env.dataset().import(shape), { ...options, maxErrors })
}

0 comments on commit 5cbbb0f

Please sign in to comment.