Skip to content

Commit 035a804

Browse files
committed
fix: windows crlf
1 parent c70c0a7 commit 035a804

File tree

12 files changed

+27
-28
lines changed

12 files changed

+27
-28
lines changed

bin/to-js.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env node
22

3-
import parser from '../lib/parser.cjs'
4-
import { transformError } from '../lib/util.js'
3+
import { fromDSL } from '../lib/from-dsl.js'
54
import { pkgDecjsor } from './util.js'
65
import { collectInput } from './collect-input.js'
76
import { Builder, safeReference } from '../lib/typed.js'
@@ -21,7 +20,7 @@ export async function toJS (files, options) {
2120
for (const { filename, contents } of input) {
2221
try {
2322
/** @type {any} */
24-
const parsed = parser.parse(contents)
23+
const parsed = fromDSL(contents)
2524
if (!schema) {
2625
schema = parsed
2726
} else {
@@ -35,7 +34,7 @@ export async function toJS (files, options) {
3534
}
3635
} catch (err) {
3736
// @ts-ignore
38-
console.error(`Error parsing ${filename}: ${transformError(err).message}`)
37+
console.error(`Error parsing ${filename}: ${err.message}`)
3938
process.exit(1)
4039
}
4140
}

bin/to-json.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env node
22

3-
import parser from '../lib/parser.cjs'
4-
import { transformError } from '../lib/util.js'
3+
import { fromDSL } from '../lib/from-dsl.js'
54
import { collectInput } from './collect-input.js'
65

76
/**
@@ -33,7 +32,7 @@ export async function toJSON (files, options) {
3332
let schema = null
3433
for (const { filename, contents } of input) {
3534
try {
36-
const parsed = /** @type {Schema} */(parser.parse(contents, parseOptions))
35+
const parsed = fromDSL(contents, parseOptions)
3736
if (schema == null) {
3837
schema = parsed
3938
} else {
@@ -62,7 +61,7 @@ export async function toJSON (files, options) {
6261
}
6362
} catch (err) {
6463
// @ts-ignore
65-
console.error(`Error parsing ${filename}: ${transformError(err).message}`)
64+
console.error(`Error parsing ${filename}: ${err.message}`)
6665
process.exit(1)
6766
}
6867
}

bin/to-schema.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#!/usr/bin/env node
22

3-
import parser from '../lib/parser.cjs'
3+
import { fromDSL } from '../lib/from-dsl.js'
44
import { toDSL } from '../lib/to-dsl.js'
5-
import { transformError } from '../lib/util.js'
65
import { collectInput } from './collect-input.js'
76

87
let indent = ' '
@@ -22,7 +21,7 @@ export async function toSchema (files, options) {
2221
let schema
2322
for (const { filename, contents } of input) {
2423
try {
25-
const parsed = parser.parse(contents)
24+
const parsed = fromDSL(contents)
2625
if (!schema) {
2726
schema = parsed
2827
} else {
@@ -36,10 +35,12 @@ export async function toSchema (files, options) {
3635
}
3736
} catch (err) {
3837
// @ts-ignore
39-
console.error(`Error parsing ${filename}: ${transformError(err).message}`)
38+
console.error(`Error parsing ${filename}: ${err.message}`)
4039
process.exit(1)
4140
}
4241
}
4342

44-
console.log(toDSL(schema, indent))
43+
if (schema) {
44+
console.log(toDSL(schema, indent))
45+
}
4546
}

bin/to-tsdefs.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env node
22

3-
import parser from '../lib/parser.cjs'
4-
import { transformError } from '../lib/util.js'
3+
import { fromDSL } from '../lib/from-dsl.js'
54
import { pkgDecjsor } from './util.js'
65
import { collectInput } from './collect-input.js'
76
import { generateTypeScript } from '../lib/gen.js'
@@ -21,7 +20,7 @@ export async function toTSDefs (files, _options) {
2120
for (const { filename, contents } of input) {
2221
try {
2322
/** @type {any} */
24-
const parsed = parser.parse(contents, { includeComments: true, includeAnnotations: true })
23+
const parsed = fromDSL(contents, { includeComments: true, includeAnnotations: true })
2524
if (!schema) {
2625
schema = parsed
2726
} else {
@@ -35,7 +34,7 @@ export async function toTSDefs (files, _options) {
3534
}
3635
} catch (err) {
3736
// @ts-ignore
38-
console.error(`Error parsing ${filename}: ${transformError(err).message}`)
37+
console.error(`Error parsing ${filename}: ${err.message}`)
3938
process.exit(1)
4039
}
4140
}

bin/validate.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import parser from '../lib/parser.cjs'
2-
import { transformError } from '../lib/util.js'
1+
import { fromDSL } from '../lib/from-dsl.js'
32
import { collectInput } from './collect-input.js'
43

54
/**
@@ -12,10 +11,10 @@ export async function validate (files, _) {
1211

1312
for (const { filename, contents } of input) {
1413
try {
15-
parser.parse(contents)
14+
fromDSL(contents)
1615
} catch (err) {
1716
// @ts-ignore
18-
console.error(`Could not validate ${filename}: ${transformError(err).message}`) // discard useless extra info
17+
console.error(`Could not validate ${filename}: ${err.message}`) // discard useless extra info
1918
process.exit(1)
2019
}
2120
console.error(`Validated ${filename} ...`)

lib/from-dsl.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import { transformError } from './util.js'
1212
*/
1313
export function fromDSL (input, options = {}) {
1414
try {
15-
return /** @type {Schema} */(parser.parse(input, options))
15+
// Normalize line endings to LF for consistent behavior across platforms
16+
const normalizedInput = input.replace(/\r\n/g, '\n').replace(/\r/g, '\n')
17+
return /** @type {Schema} */(parser.parse(normalizedInput, options))
1618
} catch (err) {
1719
throw transformError(err)
1820
}

types/bin/to-js.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/bin/to-json.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/bin/to-schema.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

types/bin/to-tsdefs.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)