Skip to content

Commit

Permalink
added "filename" option
Browse files Browse the repository at this point in the history
  • Loading branch information
f0rmat1k committed Sep 17, 2016
1 parent 6a3d8ed commit 6acb32c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Description of the used file types.
`suffix` used by 'create' when forming file and by 'rename' for files validation (`rename` renames only described files);
`shortcuts` — list of short that you can use after `-p` key in Task of creation;
`rename` – mask for deep renaming. {{bemNode}} will be replaced to new node name. You can also use an array of masks;
`filename` — setting your own resulted file name. For example, useful when you allways need index.css or index.jsx instead of BEM names.
`template` — path to template of file type. Teamplate used when any files are created.
There are following placeholders: `{{blockName}}`, `{{elemName}}`, `{{modName}}`, `{{modVal}}` and `{{cursor}}`. When files are created this entries will be replaced with relevant part of BEM node name. And `{{cursor}}` will be deleted and used for setting cursor line number (see more at `Configuring` section). Also, you can set a hook, which will be called, when file will be created. The hook-command get file path with the first argument by replacing `{{filePath}}`.

Expand Down
4 changes: 3 additions & 1 deletion bemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@ function createFile(file, type, trg, modVal, cursorPos, hook){

if (info.isFile) trg = path.dirname(trg);

var p = path.join(trg, info.bemName + modVal + SHORTCUTS[type].suffix);
var filename = SHORTCUTS[type].filename || info.bemName + modVal + SHORTCUTS[type].suffix;

var p = path.join(trg, filename);

if (!fs.existsSync(p)) {
fse.outputFileSync(p, file);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"dependencies": {
"deps-normalize": "^2.4.1",
"fs-extra": "^0.26.2",
"fs-extra": "^0.30.0",
"minimist": "^1.2.0",
"update-notifier": "^0.5.0"
},
Expand Down

0 comments on commit 6acb32c

Please sign in to comment.