Skip to content

Commit

Permalink
Enable code coverage (#15)
Browse files Browse the repository at this point in the history
* Addresses #14
- Added `.editorconfig`
- Support for codecov
- Normalised files
* Added codecov badges to branch status table
  • Loading branch information
Silic0nS0ldier committed Jan 15, 2019
1 parent da6ceb9 commit b7a774f
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 28 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
package.json eol=lf
package-lock.json eol=lf
* eol=lf
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules/
npm-debug.log
dist/
dist/
.nyc_output
coverage
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ src/
**/*.test.d.ts
dist/index.d.ts
tsconfig.json
.gitattributes
.gitattributes
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ node_js:
- "9"
- "10"
- "11"
- "lts/*"
- "lts/*"
cache: npm
before_script: npm i -g nyc
script: nyc --reporter=lcov --reporter=text-lcov --exclude-after-remap=false npm test
after_success:
- npm i -g codecov
- codecov
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

| Branch | Status |
| ------ | ------ |
| master | [![Build Status](https://travis-ci.org/userfrosting/gulp-uf-bundle-assets.svg?branch=master)](https://travis-ci.org/userfrosting/gulp-uf-bundle-assets) |
| develop | [![Build Status](https://travis-ci.org/userfrosting/gulp-uf-bundle-assets.svg?branch=develop)](https://travis-ci.org/userfrosting/gulp-uf-bundle-assets) |
| master | [![Build Status](https://travis-ci.org/userfrosting/gulp-uf-bundle-assets.svg?branch=master)](https://travis-ci.org/userfrosting/gulp-uf-bundle-assets) [![codecov](https://codecov.io/gh/userfrosting/gulp-uf-bundle-assets/branch/master/graph/badge.svg)](https://codecov.io/gh/userfrosting/gulp-uf-bundle-assets/branch/master) |
| develop | [![Build Status](https://travis-ci.org/userfrosting/gulp-uf-bundle-assets.svg?branch=develop)](https://travis-ci.org/userfrosting/gulp-uf-bundle-assets) [![codecov](https://codecov.io/gh/userfrosting/gulp-uf-bundle-assets/branch/develop/graph/badge.svg)](https://codecov.io/gh/userfrosting/gulp-uf-bundle-assets/branch/develop) |

Orchastrates JS and CSS bundle creation in a highly efficient and configurable manner.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"types": "./dist/main.d.ts",
"scripts": {
"pretest": "tsc",
"test": "ava",
"test": "nyc ava",
"prepublishOnly": "tsc",
"prevsion": "npm test",
"version": "changelog-updater && git add CHANGELOG.md",
Expand Down
2 changes: 1 addition & 1 deletion src/catcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Readable } from "stream"
test("Catcher catches all stream content", async t => {
const input = [{}, "test", 21];
const result = [{}, "test", 21];

await TestCatcher(t, input, result);
});

Expand Down
4 changes: 2 additions & 2 deletions src/catcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Catcher extends Transform {
* Resolver for promise, may not be immeditately set.
*/
private Resolve?: (value?: any[] | PromiseLike<any[]>) => void;

constructor(logger: (value: string, level: LogLevel) => void) {
super({
objectMode: true
Expand Down Expand Up @@ -71,4 +71,4 @@ export class Catcher extends Transform {
};
resolver();
}
}
}
8 changes: 4 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { resolve as resolvePath } from "path";
/**
* Merges a collection of configurations.
* No validation is conducted, it is expected that provided inputs are all valid.
*
*
* `bundle->(BundleName)->options->sprinkle->onCollision = (replace|merge|ignore|error)` may be used to modify treatment of collided bundles.
*/
export function MergeRawConfigs(rawConfigs: Config[]): Config {
Expand Down Expand Up @@ -133,12 +133,12 @@ export function ValidateRawConfig(config: Config): void {
if (replacement === "") {
throw new Error(`Value replacement of property "VirtualPathRules" is empty.`);
}

const resolved = resolvePath(matcher);
if (matchers.indexOf(resolved) !== -1) {
throw new Error(`Value matcher of property "VirtualPathRules" is a duplicate: "${matcher}"`);
}
else
else
matchers.push(matcher);
}
}
Expand Down Expand Up @@ -293,7 +293,7 @@ interface Options {
*/
interface SprinkleOptions {
/**
*
*
*/
onCollision?: CollisionReactions | string;
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ require = require("esm")(module, {
// Caching is best reserved for projects not dev tool libraries
cache: false
});
module.exports = require("./main");
module.exports = require("./main");
16 changes: 8 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class Bundler extends Transform {
if (!config.BundlesVirtualBasePath) {
config.BundlesVirtualBasePath = process.cwd();
}

this.Logger(`Bundle resources will be resolved with: "${config.BundlesVirtualBasePath}"`, LogLevel.Silly);

// Add bundles
Expand Down Expand Up @@ -134,9 +134,9 @@ export default class Bundler extends Transform {
/**
* Attempts to create a virutal path from the provided path.
* On failure, the provided path is returned.
*
*
* @param path Absolute path to try and resolve.
*
*
* @returns New or existing path and preference.
*/
private ResolveVirtualPath(path: string): [string, number] {
Expand All @@ -157,7 +157,7 @@ export default class Bundler extends Transform {

/**
* Collects copies of applicable files to later bundle.
*
*
* @param chunk Stream chunk, may be a Vinyl object.
* @param encoding Encoding of chunk, if applicable.
* @param callback Callback to indicate processing is completed.
Expand Down Expand Up @@ -209,7 +209,7 @@ export default class Bundler extends Transform {
// Scripts
this.Logger("Starting bundling of scripts", LogLevel.Normal);
let [chunks, resultsMap] = await BundlesProcessor(this.ResolvedFiles, this.ScriptBundles, this.Bundlers.Scripts, this.Logger);


for (const chunk of chunks) {
this.push(chunk);
Expand All @@ -223,15 +223,15 @@ export default class Bundler extends Transform {
// Styles
this.Logger("Starting bundling of styles", LogLevel.Normal);
[chunks, resultsMap] = await BundlesProcessor(this.ResolvedFiles, this.StyleBundles, this.Bundlers.Styles, this.Logger);


for (const chunk of chunks) {
this.push(chunk);
}

for (const [name, paths] of resultsMap)
this.BundleResultsMap.set(name, paths);

this.Logger("Completed bundling of styles", LogLevel.Normal);

this.Logger("All bundles have been built", LogLevel.Normal);
Expand Down
2 changes: 1 addition & 1 deletion src/plugin-details.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* Plugin name used for logging and errors.
*/
export const PluginName = "gulp-uf-bundle-assets";
export const PluginName = "gulp-uf-bundle-assets";
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"noEmitHelpers": true,
"declaration": true,
"target": "es2017",
"outDir": "./dist/"
"outDir": "./dist/",
"sourceMap": true
}
}
}

0 comments on commit b7a774f

Please sign in to comment.