mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-01-09 05:26:58 -06:00
PR-069494: fix npx.
This commit is contained in:
parent
c87d1dadfa
commit
32cb7fc7fd
31
bin/cli.js
31
bin/cli.js
@ -29,13 +29,12 @@ const replaceTextOnFile = ({
|
||||
textReplace,
|
||||
arrOfObjectsBeReplaced
|
||||
}) => {
|
||||
const data = file => {
|
||||
try{
|
||||
return fs.readFileSync(file, 'utf8');
|
||||
} catch (e) {
|
||||
console.error(`Failed to read file ${file}`, e);
|
||||
return false;
|
||||
}
|
||||
let data
|
||||
try{
|
||||
data = fs.readFileSync(file, 'utf8');
|
||||
} catch (e) {
|
||||
console.error(`Failed to read file ${file}`, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
let result
|
||||
@ -51,18 +50,12 @@ const replaceTextOnFile = ({
|
||||
result = data.replace(textToBeReplaced, textReplace).replace(/^\s*[\r\n]/gm, ' ');
|
||||
}
|
||||
|
||||
const finalFile = file => {
|
||||
try{
|
||||
return fs.writeFileSync(file, result, 'utf8');
|
||||
} catch (e) {
|
||||
console.error(`Failed to read file ${file}`, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(!finalFile) {
|
||||
process.exit(-1);
|
||||
}else{
|
||||
console.log('Text replaced')
|
||||
try{
|
||||
console.log('text changed')
|
||||
fs.writeFileSync(file, result, 'utf8');
|
||||
} catch (e) {
|
||||
console.error(`Failed to read file ${file}`, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@aleleba/create-react-ssr",
|
||||
"version": "3.0.47",
|
||||
"version": "3.0.48",
|
||||
"description": "Starter Kit of server side render of react",
|
||||
"bin": "./bin/cli.js",
|
||||
"main": "src/server/index",
|
||||
|
Loading…
Reference in New Issue
Block a user