Skip to content

Commit 0d23eff

Browse files
authored
Merge pull request #1570 from bhldev/feature-options-keys
FEATURE - Expose Grunt Option Keys for Ease of Use
2 parents ee70306 + 85e5246 commit 0d23eff

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/grunt/option.js

+5
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ option.flags = function() {
3131
(typeof val === 'boolean' ? '' : '=' + val);
3232
});
3333
};
34+
35+
// Get all option keys
36+
option.keys = function() {
37+
return Object.keys(data);
38+
};

test/grunt/option_test.js

+11
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,15 @@ exports.option = {
3838
test.deepEqual(grunt.option.flags(), ['--foo=bar', '--there', '--obj=[object Object]']);
3939
test.done();
4040
},
41+
'option.keys': function(test) {
42+
test.expect(1);
43+
grunt.option.init({
44+
foo: 'bar',
45+
there: true,
46+
obj: {foo: 'bar'},
47+
arr: []
48+
});
49+
test.deepEqual(grunt.option.keys(), ['foo', 'there', 'obj', 'arr']);
50+
test.done();
51+
}
4152
};

0 commit comments

Comments
 (0)