Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

Added option to disable file extension check #8

Open
wants to merge 4 commits 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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,23 @@ grunt.initConfig({
});
```

#### Ignore file extension

By default, only files with the `.properties` file extension are processed. This is helpful if there are different file types in a directory and only the property files should be processed. You can set the option `ignoreFileExtension` to enable processing property files with another extension.

```js
grunt.initConfig({
propertiesToJSON: {
main: {
src: ['path/to/properties/properties.with.other.extension'],
options: {
ignoreFileExtension: true
}
}
}
});
```

## License

This project is released under the MIT license.
8 changes: 6 additions & 2 deletions tasks/properties-to-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function(grunt) {
dataList = [];

f.src.forEach(function(src) {
if (src.substr(-11) !== '.properties') {
if (!options.ignoreFileExtension && src.substr(-11) !== '.properties') {
return;
}
if (!grunt.file.exists(src)) {
Expand All @@ -93,7 +93,11 @@ module.exports = function(grunt) {
dataList.push(data);
} else {
dest = f.dest ? path.join(f.dest, path.basename(src)) : src;
dest = dest.replace('.properties','.json');
if (src.substr(-11) !== '.properties') {
dest += '.json';
} else {
dest = dest.replace('.properties','.json');
}
writeFile(data, dest);
}
});
Expand Down