Skip to content

Commit f8e4ec6

Browse files
author
Lukas Oppermann
committed
add root flag
1 parent c573731 commit f8e4ec6

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

cli.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ const cli = meow(`
1111
1212
Options
1313
--manifest, -m Specify the path to the manifest file, default rev-manifest.json
14+
--root, -r Specify a root path this will be removed from the file path in the manifest
1415
1516
Examples
1617
$ node-file-rev assets/css/app.css,assets/js/app.js --manifest=assets/rev-manifest.json
1718
`, {
18-
flags: {
19-
manifest: {
20-
type: 'string',
21-
alias: 'm',
19+
flags: {
20+
manifest: {
21+
type: 'string',
22+
alias: 'm',
2223
default: 'rev-manifest.json'
23-
}
24+
},
25+
root: {
26+
type: 'string',
27+
alias: 'r'
28+
}
2429
}
2530
})
2631
nodeFileRev(cli.input[0], cli.flags, cli)

node-file-rev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = (files, flags, cli) => {
2828
// If the file doesn't exist, the content will be an empty object by default.
2929
let jsonFile = editJsonFile(flags.manifest)
3030
// add file version
31-
jsonFile.set(filePath.replace(/\./g, '\\.'), newFilename)
31+
jsonFile.set(filePath.replace(/\./g, '\\.').replace(flags.root,''), newFilename.replace(flags.root,''))
3232
// save to json
3333
jsonFile.save()
3434
})
File renamed without changes.

0 commit comments

Comments
 (0)