-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fac0f7
commit b1dc381
Showing
7 changed files
with
260 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const { mkdirSync, readdirSync, lstatSync, readFileSync, writeFileSync } = require('fs'); | ||
|
||
function processDir(src, dest) { | ||
mkdirSync(dest, { recursive: true }); | ||
|
||
readdirSync(src) | ||
.forEach(name => { | ||
const currentPath = path.join(src, name); | ||
const destPath = path.join(dest, name); | ||
const currentStats = lstatSync(currentPath); | ||
if (currentStats.isDirectory()) { | ||
processDir(currentPath, destPath); | ||
return; | ||
} | ||
|
||
writeFileSync( | ||
destPath, | ||
readFileSync(currentPath).toString().replace(/from '(\.[.\\/-\w]+)'/gm, "from '$1.ts'"), | ||
); | ||
}); | ||
} | ||
|
||
const src = process.argv[2]; // './src' | ||
const dest = process.argv[3]; // './dist' | ||
processDir(src, dest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const { readdirSync, lstatSync, readFileSync, writeFileSync, unlinkSync } = require('fs'); | ||
|
||
function processDir(src) { | ||
readdirSync(src) | ||
.filter(name => !/.d.ts$/.test(name)) | ||
.forEach(name => { | ||
const currentPath = path.join(src, name); | ||
const currentStats = lstatSync(currentPath); | ||
if (currentStats.isDirectory()) { | ||
processDir(currentPath); | ||
return; | ||
} | ||
|
||
writeFileSync( | ||
currentPath.replace(/\.js$/, '.mjs'), | ||
readFileSync(currentPath).toString().replace(/from '(\.[.\\/-\w]+)'/gm, "from '$1.mjs'"), | ||
); | ||
unlinkSync(currentPath); | ||
}); | ||
} | ||
|
||
const src = process.argv[2]; // './dist' | ||
processDir(src); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
"name": "jsonparse", | ||
"description": "Streaming JSON parser in Javascript for Node.js and the browser", | ||
"version": "0.0.1", | ||
"main": "./dist/index.js", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/mjs/index.js", | ||
"browser": "./dist/umd/index.js", | ||
"types": "./dist/index.d.ts", | ||
"author": "Juanjo Diaz <[email protected]>", | ||
"repository": { | ||
|
@@ -11,15 +13,25 @@ | |
}, | ||
"bugs": "https://github.com/juanjoDiaz/jsonparse2/issues", | ||
"devDependencies": { | ||
"@types/node": "^14.0.23", | ||
"tap": "^14.10.7" | ||
"@types/node": "^14.0.24", | ||
"rollup": "^2.22.1", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"tap": "^14.10.7", | ||
"typescript": "^3.9.7" | ||
}, | ||
"scripts": { | ||
"build:deno": "node build.deno.js ./src ./dist/deno", | ||
"build:umd": "rollup -c", | ||
"build:cjs": "tsc --module commonjs --outDir ./dist/cjs", | ||
"build:mjs": "tsc --module esnext --outDir ./dist/mjs && node build.mjs.js ./dist/mjs", | ||
"build": "npm run build:deno && npm run build:umd && npm run build:cjs && npm run build:mjs", | ||
"dev": "rollup -c -w", | ||
"test": "tap test/*.ts" | ||
}, | ||
"license": "MIT", | ||
"tags": [ | ||
"json", | ||
"stream" | ||
] | ||
], | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import typescript from 'rollup-plugin-typescript2'; | ||
import pkg from './package.json'; | ||
|
||
export default [ | ||
{ | ||
input: 'src/index.ts', | ||
output: { | ||
file: pkg.browser, | ||
format: 'umd', | ||
name: 'jsonparse' | ||
}, | ||
plugins: [ | ||
typescript({ | ||
tsconfigOverride: { | ||
compilerOptions: { | ||
target: "es5", | ||
} | ||
} | ||
}) | ||
] | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters