diff --git a/package.json b/package.json index 0629f56..df789a9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "./dist/index.js", "types": "./dist/index.d.ts", - "files": ["dist/**/*"], + "files": ["./time-ranges.pegjs", "./dist/**/*"], "scripts": { "test": "npm run build && node dist/test.js", "test:watch": "nodemon --watch tsconfig.json --watch index.ts --watch parser.ts --watch time-ranges.pegjs --exec \"npm run test\"", diff --git a/parser.ts b/parser.ts index d5b9518..f52c0d7 100644 --- a/parser.ts +++ b/parser.ts @@ -1,5 +1,7 @@ import fs from "fs"; +import path from "path"; import peg from "pegjs"; -const grammar = fs.readFileSync("./time-ranges.pegjs", "utf-8"); +const grammarPath = path.resolve(__dirname, "..", "time-ranges.pegjs"); +const grammar = fs.readFileSync(grammarPath, "utf-8"); export const parser = peg.generate(grammar);