-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-player-html.js
30 lines (26 loc) · 1.09 KB
/
update-player-html.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
30
const fs = require('fs');
const originFilePath = "jsav-exercise-player/player.html";
const destinationFilePath = "jsav-player-application-test-server/public/jsav-player/player.html";
try {
console.log('Reading origin file', originFilePath);
var originPlayerHTML = fs.readFileSync(originFilePath, 'utf-8');
console.log('Reading destination file', destinationFilePath);
var destPlayerHTML = fs.readFileSync(destinationFilePath, 'utf-8');
} catch (err) {
console.warn('Failed reading file', err);
}
try {
console.log('Getting body tags content');
const catchBodyRegExp = /<body>[\s\S]*(.*?)<\/body>/
var bodyOriginalHTML = catchBodyRegExp.exec(originPlayerHTML)[0]
var bodyDestinationHTML = catchBodyRegExp.exec(destPlayerHTML)[0]
} catch (err) {
console.warn('Failed getting body tag content', err);
}
try {
console.log('Writing destination file', destinationFilePath);
const newDestinationFile = destPlayerHTML.split(bodyDestinationHTML).join(bodyOriginalHTML);
fs.writeFileSync(destinationFilePath, newDestinationFile);
} catch (err) {
console.warn('Failed writing to file', err);
}