Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
grunt-pretest
Advanced tools
Readme
Grunt plugin to run task only when specified tests are passed.
This plugin requires Grunt >=0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-pretest --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-pretest');
The pretest
task is multi task.
In your project's Gruntfile, add a section named pretest
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
pretest: {
options: {
// Task-specific options go here.
},
your_target: {
options: {
// Target-specific options go here.
}
},
},
});
Type: any
Default value: true
Specifies test or array of tests that should be passed to run a task. Any test that is not a function is converted to boolean value. If test is a function, its result is used as test value. The following parameters are passed into the function:
grunt
objectIf test function returns a non-empty string, a non-empty array or a function,
the returned value will be used as task that should be run instead of task
option.
The task described in task
option or returned from a test function will be run only if:
true
value when testConnect
option is and
true
value when testConnect
option is or
Type: String
Default value: and
A boolean connector that should be used when array of tests is specified in test
option.
Valid values are the following: and
, or
(case-insensitive). Any other value is treated as and
.
Type: String
| Array of String
| Function
Describes task(s) that should be run when test is passed.
This option can be omitted if test function returns the necessary task(s).
Each string should specify task in usual format (e.g. concat:foo
, bar:testing:123
).
If a function is set as task, the following parameters will be passed into the function:
grunt
objectIf task function returns a non-empty string or a non-empty array, the returned value will be used as argument for grunt.task.run
(i.e. defines task(s) that should be run after the processed pretest
task).
Data object that is passed into test and task function has the following fields:
task
- value of task
optionpretest
- reference to the object that represents the processed pretest
task (see Inside Tasks for available properties)options
- options of the processed pretest
tasksource
- a source item that is being processedIn this example, the concat
task will be run only if directory specified by configDir
configuration parameter exists.
grunt.initConfig({
pretest: {
configDir: {
options: {
test: function(data, grunt) {
return grunt.file.isDir(grunt.config.get("configDir"));
},
task: 'concat:config_files'
}
}
}
});
In the following example, the test function returns a task that should be run depending on value of target
option.
grunt.initConfig({
pretest: {
configDir: {
options: {
test: function(data, grunt) {
var target = grunt.option("target");
return target
? "prepare:" + (target === "prod" ? "product" : "dev")
: false;
}
}
}
}
});
It is possible to specify sources for which tests and tasks should be run.
grunt.initConfig({
pretest: {
sourceList: {
src: ["a.json", "b.xml", "c.data"],
options: {
test: function(data, grunt) {
var runTask = true;
try {
fs.statSync(data.source);
}
catch (e) {
runTask = false;
}
return runTask;
},
task: function(data, grunt) {
return "some-task:" + data.source;
}
}
}
}
});
See Gruntfile.js for more examples.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
1.0.0 / 2016-03-18
0.2.0 / 2016-03-07
0.1.0 / 2016-02-03
task
option can be omitted if test function returns task that should be run.pretest
task.FAQs
Grunt plugin to run task only when specified tests are passed
The npm package grunt-pretest receives a total of 1 weekly downloads. As such, grunt-pretest popularity was classified as not popular.
We found that grunt-pretest demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.