-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from orchitech/rollup-build
Add project bundling with base linter
- Loading branch information
Showing
13 changed files
with
1,555 additions
and
236 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,5 @@ | ||
{ | ||
"presets": [ | ||
["@babel/env", {}] | ||
] | ||
} |
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 @@ | ||
dist |
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,7 @@ | ||
{ | ||
"extends": "airbnb-base", | ||
"rules": { | ||
"no-plusplus": "off", | ||
"max-classes-per-file": "off" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -59,3 +59,6 @@ typings/ | |
|
||
# next.js build output | ||
.next | ||
|
||
# Build directory | ||
dist |
Large diffs are not rendered by default.
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 |
---|---|---|
@@ -1,26 +1,44 @@ | ||
{ | ||
"name": "union-replacer", | ||
"version": "0.0.9", | ||
"version": "1.0.0", | ||
"description": "One-pass String.prototype.replace-like processor with multiple regexps and replacements", | ||
"main": "index.js", | ||
"main": "dist/union-replacer.cjs.js", | ||
"module": "dist/union-replacer.esm.js", | ||
"browser": "dist/union-replacer.umd.js", | ||
"scripts": { | ||
"test": "node test/union-replacer-test.js && node test/readme-test.js" | ||
"lint": "eslint .", | ||
"prebuild": "npm run lint", | ||
"build": "rollup -c", | ||
"pretest": "npm run build", | ||
"test": "jasmine JASMINE_CONFIG_PATH=test/jasmine.json", | ||
"prepublish": "npm test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/orchitech/union-replacer.git" | ||
}, | ||
"devDependencies": { | ||
"standard": "^14.0.0", | ||
"@babel/core": "^7.7.2", | ||
"@babel/plugin-transform-runtime": "^7.6.2", | ||
"@babel/preset-env": "^7.7.1", | ||
"colors": "^1.4.0", | ||
"diff": "^4.0.0", | ||
"colors": "^1.4.0" | ||
"eslint": "^6.6.0", | ||
"eslint-config-airbnb-base": "^14.0.0", | ||
"jasmine": "^3.5.0", | ||
"rollup": "^1.26.3", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"standard": "^14.0.0" | ||
}, | ||
"keywords": [ | ||
"regexp", | ||
"replace", | ||
"union", | ||
"alternation" | ||
], | ||
"files": [ | ||
"dist" | ||
], | ||
"author": "Martin Cizek <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
|
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,16 @@ | ||
import babel from 'rollup-plugin-babel'; | ||
import pkg from './package.json'; | ||
|
||
export default [ | ||
{ | ||
input: 'src/UnionReplacer.js', | ||
plugins: [ | ||
babel({ exclude: 'node_modules/**' }), | ||
], | ||
output: [ | ||
{ file: pkg.main, format: 'cjs' }, | ||
{ file: pkg.module, format: 'es' }, | ||
{ file: pkg.browser, name: 'UnionReplacer', format: 'umd' }, | ||
], | ||
}, | ||
]; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"env": { | ||
"jasmine": true | ||
}, | ||
"rules": { | ||
"import/no-unresolved": "off" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"spec_dir": "test", | ||
"spec_files": [ | ||
"**/*[sS]pec.js", | ||
"!**/*nospec.js" | ||
], | ||
"stopSpecOnExpectationFailure": false, | ||
"random": false | ||
} |
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 |
---|---|---|
@@ -1,50 +1,50 @@ | ||
const fs = require('fs'); | ||
const UnionReplacer = require("../src/UnionReplacer") | ||
require('colors'); | ||
const Diff = require('diff'); | ||
// const fs = require('fs'); | ||
// const UnionReplacer = require("../src/UnionReplacer") | ||
// require('colors'); | ||
// const Diff = require('diff'); | ||
|
||
const readme = fs.readFileSync(__dirname + '/../README.md', 'utf8'); | ||
var docContext = { | ||
asserted: false, | ||
actual: null, | ||
UnionReplacer: UnionReplacer | ||
}; | ||
const docBlockRe = /^(([`~])\2{2,})[ \t]*(.*?)\s+([\s\S]*?)(?:^\1\2*[ \t]*$|(?![\s\S]))/gm; | ||
const testify = new UnionReplacer([ | ||
[/^(?:[ \t\w{}.]+=)?\s*\brequire\b.*$/, '// $&'], | ||
[/^[ \t]*(var|const|let)\b/, '/* $1 */'], | ||
[/^[ \t]*console\.log\((.*?)\)[;\s]*(?![\s\S])/, 'actual = $1; asserted = true;'] | ||
]); | ||
// const readme = fs.readFileSync(__dirname + '/../README.md', 'utf8'); | ||
// var docContext = { | ||
// asserted: false, | ||
// actual: null, | ||
// UnionReplacer: UnionReplacer | ||
// }; | ||
// const docBlockRe = /^(([`~])\2{2,})[ \t]*(.*?)\s+([\s\S]*?)(?:^\1\2*[ \t]*$|(?![\s\S]))/gm; | ||
// const testify = new UnionReplacer([ | ||
// [/^(?:[ \t\w{}.]+=)?\s*\brequire\b.*$/, '// $&'], | ||
// [/^[ \t]*(var|const|let)\b/, '/* $1 */'], | ||
// [/^[ \t]*console\.log\((.*?)\)[;\s]*(?![\s\S])/, 'actual = $1; asserted = true;'] | ||
// ]); | ||
|
||
let m, total = 0, failed = 0, passed = 0; | ||
while ((m = docBlockRe.exec(readme)) !== null) { | ||
let infoStr = m[3]; | ||
let code = m[4].trim().replace(/\r?\n/, '\n'); | ||
let asserted = docContext.asserted; | ||
docContext.asserted = false; | ||
// let m, total = 0, failed = 0, passed = 0; | ||
// while ((m = docBlockRe.exec(readme)) !== null) { | ||
// let infoStr = m[3]; | ||
// let code = m[4].trim().replace(/\r?\n/, '\n'); | ||
// let asserted = docContext.asserted; | ||
// docContext.asserted = false; | ||
|
||
if (/^.*no unionreplacer/i.test(code)) { | ||
continue; | ||
} | ||
// if (/^.*no unionreplacer/i.test(code)) { | ||
// continue; | ||
// } | ||
|
||
if (infoStr === 'js') { | ||
code = testify.replace(code); | ||
(new Function(`with (this) {\n ${code}\n}`)).call(docContext); | ||
} else if (infoStr === '' && asserted) { | ||
total++; | ||
if (code === docContext.actual) { | ||
passed++; | ||
} else { | ||
failed++; | ||
console.log('Assertion failed:'); | ||
let diff = Diff.diffWordsWithSpace(code, docContext.actual); | ||
diff.forEach((part) => { | ||
let color = part.added ? 'green' : part.removed ? 'red' : 'grey'; | ||
process.stderr.write(part.value[color]); | ||
}); | ||
process.stderr.write('\n'); | ||
} | ||
} | ||
} | ||
// if (infoStr === 'js') { | ||
// code = testify.replace(code); | ||
// (new Function(`with (this) {\n ${code}\n}`)).call(docContext); | ||
// } else if (infoStr === '' && asserted) { | ||
// total++; | ||
// if (code === docContext.actual) { | ||
// passed++; | ||
// } else { | ||
// failed++; | ||
// console.log('Assertion failed:'); | ||
// let diff = Diff.diffWordsWithSpace(code, docContext.actual); | ||
// diff.forEach((part) => { | ||
// let color = part.added ? 'green' : part.removed ? 'red' : 'grey'; | ||
// process.stderr.write(part.value[color]); | ||
// }); | ||
// process.stderr.write('\n'); | ||
// } | ||
// } | ||
// } | ||
|
||
console.log(`Passed ${passed} of ${total} tests.`); | ||
// console.log(`Passed ${passed} of ${total} tests.`); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.