Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Give option to not override files #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,23 @@ Type: `String`
The path to the Karma configuration file.

#### options.action
Type: `String`
Type: `String`
Default: `run`

One of the following:

* **`run`**: Start the server, run tests once, then exit.
* **`watch`**: Start the server, run tests once, then watch for changes and run when files change.

#### options.noOverrideFiles
Type: `Boolean`
Default: `false`

One of the following:

* **`true`**: Use paths supplied from `gulp.src()` as the `files` option for Karma.
* **`false`**: Don't do that (helpful when using the `{included: false}` option, such as running with RequireJS).

#### options.*

Any Karma option can be passed as part of the options object. See [Karma Configuration] for a complete list of options. **Note:** It's best practice to put options in your Karma config file.
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var server = require('karma').server;
var karmaPlugin = function(options) {
var child;
var stream;
var overrideFiles = !options.noOverrideFiles;
var files = [];

options = extend({
Expand All @@ -24,6 +25,7 @@ var karmaPlugin = function(options) {

// Remove option in case Karma uses it in the future
delete options.action;
delete options.noOverrideFiles;

if (action === 'watch') {
// Never set singleRun in background mode
Expand Down Expand Up @@ -91,7 +93,7 @@ var karmaPlugin = function(options) {
function endStream() {
// Override files if they were piped
// This doesn't work with the runner, but works fine with singleRun and autoWatch
if (files.length) {
if (files.length && overrideFiles) {
options.files = files;
}

Expand Down