-
Notifications
You must be signed in to change notification settings - Fork 0
/
replace.js
29 lines (24 loc) · 866 Bytes
/
replace.js
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
//Load the library and specify options
const replace = require('replace-in-file');
const someProcessingA = (input) => {
if (!!input.match(/<img src\=\"[a-zA-Z]/g)) return input.replace(/<img src\=\"/g, '<img src\=\"./');
return input;
}
const someProcessingB = (input) => input.replace(/https\:\/\/github.com\/getify\/You-Dont-Know-JS\/blob\/2nd-ed\/external-logos\//g, './external-logos/');
replace.sync({
files: './docs/ydkjs/**/*.md',
processor: [someProcessingA, someProcessingB],
});
replace.sync({
files: './docs/index.md',
from: '%time%',
to: new Date().toString(),
});
replace.sync({
files: './docs/ydkjs/objects-classes/foreword.md',
from: '[You Don\'t Know JS Yet: Objects & Classes]()',
to: '[You Don\'t Know JS Yet: Objects & Classes](README.md)',
});
console.log('');
console.log('🚀 ~ Replace Success ✅');
console.log('');