Fix: Error message for the build step now includes the file name

main
Jackson Morgan 1 year ago
parent 036c26f797
commit 12eb9c74c8
  1. 3
      packages/cli/package.json
  2. 16
      packages/cli/src/build.ts
  3. 19
      packages/cli/test/.shapes/foafProfile.shex

@ -19,7 +19,8 @@
"test": "jest --coverage",
"test:watch": "jest --watch",
"prepublishOnly": "npm run test && npm run build",
"lint": "eslint src/** --fix --no-error-on-unmatched-pattern"
"lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
"build:ldo": "./dist/index.js build --input test/.shapes --output test/.ldo"
},
"repository": {
"type": "git",

@ -38,9 +38,19 @@ export async function build(options: BuildOptions) {
"utf8",
);
// Convert to ShexJ
const schema: Schema = parser
.construct("https://ldo.js.org/")
.parse(shexC);
let schema: Schema;
try {
schema = parser.construct("https://ldo.js.org/").parse(shexC);
} catch (err) {
const errMessage =
err instanceof Error
? err.message
: typeof err === "string"
? err
: "Unknown Error";
console.error(`Error processing ${file.name}: ${errMessage}`);
return;
}
// Convert the content to types
const [typings, context] = await schemaConverterShex(schema);
await Promise.all(

@ -0,0 +1,19 @@
# This shape is provided by default as an example
# You can create your own shape to fit your needs using ShEx (https://shex.io)
# Also check out https://shaperepo.com for examples of more shapes.
PREFIX ex: <https://example.com/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
ex:FoafProfile EXTRA a {
a [ foaf:Person ]
// rdfs:comment "Defines the node as a Person (from foaf)" ;
foaf:name xsd:string ?
// rdfs:comment "Define a person's name." ;
foaf:img xsd:string ?
// rdfs:comment "Photo link but in string form"
foaf:knows @ex:FoafProfile *
// rdfs:comment "A list of WebIds for all the people this user knows." ;
}
Loading…
Cancel
Save