Skip to content

Commit

Permalink
add in splitSegment option
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Ingram committed Jun 13, 2019
1 parent c5fe562 commit 37d53b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,21 @@ $ yarn add babel-plugin-console-source -D
````javascript
{
"plugins": [

// consoleSource // No options required

// You can pass in the following options
["console-source", {

"segments": 1
"segments": 1, // NOT REQUIRED
// 0 = full file path (Default)
// 1 = file name ONLY
// 2 = file name and last segment

"splitSegment": '/' // How to split the path - NOT REQUIRED
// Default is / for Linux and OSX
// Windows users can use "\\" here if needed

}]
]
}
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = () => {
if(typeof opts.resolveFile === 'function') {
file = opts.resolveFile(file);
} else if (!opts || opts.segments !== 0) {
file = state.file.opts.filename.split("/");
file = state.file.opts.filename.split(((opts.splitSegment) ? opts.splitSegment : '/'));
let segs = file.slice(Math.max(file.length - opts.segments));
file = segs.join('/');
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-console-source",
"version": "2.0.3",
"version": "2.0.4",
"main": "index.js",
"repository": "https://github.com/peteringram0/babel-console-source",
"author": "Peter Ingram <peter.ingram0@gmail.com>",
Expand Down
5 changes: 3 additions & 2 deletions tests/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ module.exports = {

plugins: [
[consoleSource, {
"segments": 2
"segments": 1,
"splitSegment": "/"
}]
]

}
},
]
}
};
};

0 comments on commit 37d53b6

Please sign in to comment.