forked from furzeface/cachebust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·38 lines (30 loc) · 913 Bytes
/
cli.js
File metadata and controls
executable file
·38 lines (30 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /usr/bin/env node
'use strict';
var cachebust = require('./lib/cachebust'),
fs = require('fs'),
filePath;
if (process.argv[2] === undefined) {
return console.log('Supply an html file as the first argument');
}
filePath = process.argv[2];
if (filePath.indexOf('.html') > -1) {
var options = {
basePath: 'test/fixtures/',
type: (process.argv[3]) ? process.argv[3] : 'MD5'
};
if (options.type === 'constant') {
if (process.argv[4] == undefined) {
throw new Error('constant should have a 3rd parameter representing value of the constant')
}
options.value = process.argv[4];
}
fs.readFile(filePath, 'utf8', function (err, html) {
if (err) {
throw err;
}
console.log(cachebust.busted(html, options));
});
}
if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
return console.log(require('./package').version);
}