Skip to content
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
32 changes: 29 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,30 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
name: Install Python
with:
python-version: "3.x"

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
cache: "npm"
cache-dependency-path: package-lock.json

# Workaround for intermittent npm cache/tarball corruption on runners
- name: Clean npm cache
run: npm cache clean --force

# Install Node dependencies once (not concurrently inside tox envs)
- name: Install node modules
run: npm ci --no-audit --no-fund

- name: Build JS bundle
run: npm run build

- name: Install tox
run: python -m pip install tox

Expand All @@ -26,23 +45,30 @@ jobs:

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
name: Install Python
with:
python-version: "3.x"

- name: Install Node
uses: actions/setup-node@v3
with:
node-version: "latest"
cache: "npm"
cache-dependency-path: package-lock.json

- name: Install node modules
run: npm ci
- name: Clean npm cache
run: npm cache clean --force

- name: Install node modules
run: npm ci --no-audit --no-fund

- name: Build JS bundle
run: npm run build

- name: Install tox
run: python -m pip install tox

- name: Run test suite
run: python -m tox -e py3
run: python -m tox -e py3
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ node_modules/
venv/
tdd/lib/*.js
tdd/lib/__pycache__/
.DS_Store
.DS_Store.vscode/
27 changes: 17 additions & 10 deletions js-src/frame-jsonld.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@ const rl = readline.createInterface({
});

rl.on('line', async (input) => {
const inputObjects = JSON.parse(input);
const ntriples = inputObjects[0]["ntriples"];
const framedata = inputObjects[1];
const doc = await fromRDF(ntriples, {
format: "application/n-quads",
useNativeTypes: "true",
});
const framed = await jsonldFrame(doc, framedata);
console.log(JSON.stringify(framed, null, 2));
rl.close();
try {
const inputObjects = JSON.parse(input);
const ntriples = inputObjects[0]["ntriples"];
const framedata = inputObjects[1];
const doc = await fromRDF(ntriples, {
format: "application/n-quads",
useNativeTypes: "true",
});
const framed = await jsonldFrame(doc, framedata);
console.log(JSON.stringify(framed, null, 2));
rl.close();
} catch (error) {
// Best practice: write to stderr and return non-zero exit code
console.error(`JSON-LD Framing failed: ${error.message}`);
rl.close();
process.exit(1);
}
});
Loading
Loading