Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrod Overson committed Oct 24, 2012
0 parents commit ee4da5d
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions .npmignore
@@ -0,0 +1 @@
/node_modules/
13 changes: 13 additions & 0 deletions LICENSE
@@ -0,0 +1,13 @@
Copyright 2012 OneHealth Solutions, Inc

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
47 changes: 47 additions & 0 deletions README.md
@@ -0,0 +1,47 @@
# grunt-env

Specify an ENV configuration as a task, e.g.

```
grunt.registerTask('dev', 'env:dev lint test');
grunt.registerTask('build', 'env:build lint test');
```

## Getting Started
Install this grunt plugin next to your project's [grunt.js gruntfile][getting_started] with: `npm install grunt-env`

Then add this line to your project's `grunt.js` gruntfile:

```javascript
grunt.loadNpmTasks('grunt-env');
```

[grunt]: http://gruntjs.com/
[getting_started]: https://github.com/gruntjs/grunt/blob/master/docs/getting_started.md

## Configuration

```js
env : {
dev : {
env_var : 'env value'
}
}
```

## Contributing
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][grunt].

## Release History

- 0.1.0 Initial release

## License

Copyright (c) 2012 OneHealth Solutions, Inc
Licensed under the Apache 2.0 license.

## Author

Jarrod Overson
2 changes: 2 additions & 0 deletions bin/grunt-env
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('grunt').npmTasks('grunt-env').cli();
46 changes: 46 additions & 0 deletions grunt.js
@@ -0,0 +1,46 @@
module.exports = function(grunt) {
"use strict";

// Project configuration.
grunt.initConfig({
test: {
files: ['test/**/*.js']
},
lint: {
files: ['grunt.js', 'tasks/**/*.js', 'test/**/*.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'default'
},
env : {
test : {
foo : 'bar'
}
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
node: true,
es5: true
},
globals: {}
}
});

// Load local tasks.
grunt.loadTasks('tasks');

// Default task.
grunt.registerTask('default', 'lint test');

};
40 changes: 40 additions & 0 deletions package.json
@@ -0,0 +1,40 @@
{
"name": "grunt-env",
"description": "Specify an ENV configuration for future tasks in the chain",
"version": "0.1.0",
"homepage": "https://github.com/onehealth/grunt-env",
"author": {
"name": "Jarrod Overson",
"email": "jsoverson@gmail.com",
"url": "http://jarrodoverson.com/"
},
"repository": {
"type": "git",
"url": "git://github.com/onehealth/grunt-env.git"
},
"bugs": {
"url": "https://github.com/onehealth/grunt-env/issues"
},
"licenses": [
{
"type": "Apache2",
"url": "https://github.com/onehealth/grunt-env/blob/master/LICENSE-Apache2"
}
],
"main": "grunt.js",
"bin": "bin/grunt-env",
"engines": {
"node": "*"
},
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"grunt": "~0.3.17"
},
"keywords": [
"gruntplugin",
"env",
"config"
]
}
22 changes: 22 additions & 0 deletions tasks/env.js
@@ -0,0 +1,22 @@
/*
* grunt-env
* https://github.com/onehealth/grunt-env
*
* Copyright (c) 2012 OneHealth Solutions, inc
* Licensed under the Apache 2.0 license.
*/

"use strict";

function task(grunt) {
grunt.registerMultiTask('env', 'Your task description goes here.', function() {
task.run(this.data);
});

task.run = function(config) {
grunt.utils._.extend(process.env, config);
};
}

module.exports = task;

41 changes: 41 additions & 0 deletions test/env_test.js
@@ -0,0 +1,41 @@
"use strict";

var grunt = require('grunt');

/*
======== A Handy Little Nodeunit Reference ========
https://github.com/caolan/nodeunit
Test methods:
test.expect(numAssertions)
test.done()
Test assertions:
test.ok(value, [message])
test.equal(actual, expected, [message])
test.notEqual(actual, expected, [message])
test.deepEqual(actual, expected, [message])
test.notDeepEqual(actual, expected, [message])
test.strictEqual(actual, expected, [message])
test.notStrictEqual(actual, expected, [message])
test.throws(block, [error], [message])
test.doesNotThrow(block, [error], [message])
test.ifError(value)
*/

var task = require('../tasks/env');

exports['env'] = {
setUp: function(done) {
// setup here
done();
},
'helper': function(test) {
test.expect(1);
task.run({
bar : 'bar'
});
test.equal(process.env.bar, 'bar', 'Should set environment');

test.done();
}
};

0 comments on commit ee4da5d

Please sign in to comment.