mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-01-09 21:46:56 -06:00
commit
5a89c1ff33
38
bin/cli.js
38
bin/cli.js
@ -30,28 +30,24 @@ const replaceTextOnFile = ({
|
|||||||
textReplace,
|
textReplace,
|
||||||
arrOfObjectsBeReplaced
|
arrOfObjectsBeReplaced
|
||||||
}) => {
|
}) => {
|
||||||
fs.readFile(file, 'utf8', function (err,data) {
|
const data = fs.readFileSync(file, 'utf8');
|
||||||
let result
|
let result
|
||||||
if (err) {
|
if(arrOfObjectsBeReplaced){
|
||||||
return console.error(err);
|
arrOfObjectsBeReplaced.forEach( obj => {
|
||||||
}
|
if(result){
|
||||||
if(arrOfObjectsBeReplaced){
|
result = result.replace(obj.textToBeReplaced, obj.textReplace).replace(/^\s*[\r\n]/gm, ' ');
|
||||||
arrOfObjectsBeReplaced.forEach( obj => {
|
}else{
|
||||||
if(result){
|
result = data.replace(obj.textToBeReplaced, obj.textReplace).replace(/^\s*[\r\n]/gm, ' ');
|
||||||
result = result.replace(obj.textToBeReplaced, obj.textReplace).replace(/^\s*[\r\n]/gm, ' ');
|
|
||||||
}else{
|
|
||||||
result = data.replace(obj.textToBeReplaced, obj.textReplace).replace(/^\s*[\r\n]/gm, ' ');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}else{
|
|
||||||
result = data.replace(textToBeReplaced, textReplace).replace(/^\s*[\r\n]/gm, ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFile(file, result, 'utf8', function (err) {
|
|
||||||
if (err){
|
|
||||||
return console.error(err);
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
}else{
|
||||||
|
result = data.replace(textToBeReplaced, textReplace).replace(/^\s*[\r\n]/gm, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(file, result, 'utf8', function (err) {
|
||||||
|
if (err){
|
||||||
|
return console.error(err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@aleleba/create-react-ssr",
|
"name": "@aleleba/create-react-ssr",
|
||||||
"version": "3.0.45",
|
"version": "3.0.46",
|
||||||
"description": "Starter Kit of server side render of react",
|
"description": "Starter Kit of server side render of react",
|
||||||
"bin": "./bin/cli.js",
|
"bin": "./bin/cli.js",
|
||||||
"main": "src/server/index",
|
"main": "src/server/index",
|
||||||
|
Loading…
Reference in New Issue
Block a user