diff --git a/packages/cli/package.json b/packages/cli/package.json
index 87582c3..77e08a8 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -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",
diff --git a/packages/cli/src/build.ts b/packages/cli/src/build.ts
index 563fc7c..0aebb7f 100644
--- a/packages/cli/src/build.ts
+++ b/packages/cli/src/build.ts
@@ -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(
diff --git a/packages/cli/test/.shapes/foafProfile.shex b/packages/cli/test/.shapes/foafProfile.shex
new file mode 100644
index 0000000..95c472b
--- /dev/null
+++ b/packages/cli/test/.shapes/foafProfile.shex
@@ -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:
+PREFIX foaf:
+PREFIX rdfs:
+PREFIX xsd:
+
+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." ;
+}