Merge pull request #52 from aleleba/PR-069494

PR-069494: fix npx.
This commit is contained in:
Alejandro Lembke Barrientos 2022-08-05 18:53:04 -06:00 committed by GitHub
commit 8e43e93a15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 20 deletions

View File

@ -29,14 +29,13 @@ const replaceTextOnFile = ({
textReplace, textReplace,
arrOfObjectsBeReplaced arrOfObjectsBeReplaced
}) => { }) => {
const data = file => { let data
try{ try{
return fs.readFileSync(file, 'utf8'); data = fs.readFileSync(file, 'utf8');
} catch (e) { } catch (e) {
console.error(`Failed to read file ${file}`, e); console.error(`Failed to read file ${file}`, e);
return false; return false;
} }
}
let result let result
if(arrOfObjectsBeReplaced){ if(arrOfObjectsBeReplaced){
@ -51,20 +50,14 @@ const replaceTextOnFile = ({
result = data.replace(textToBeReplaced, textReplace).replace(/^\s*[\r\n]/gm, ' '); result = data.replace(textToBeReplaced, textReplace).replace(/^\s*[\r\n]/gm, ' ');
} }
const finalFile = file => {
try{ try{
return fs.writeFileSync(file, result, 'utf8'); console.log('text changed')
fs.writeFileSync(file, result, 'utf8');
} catch (e) { } catch (e) {
console.error(`Failed to read file ${file}`, e); console.error(`Failed to read file ${file}`, e);
return false; return false;
} }
} }
if(!finalFile) {
process.exit(-1);
}else{
console.log('Text replaced')
}
}
const repoName = process.argv[2]; const repoName = process.argv[2];
const gitCheckoutCommand = `git clone --depth 1 https://github.com/aleleba/create-react-ssr ${repoName}`; const gitCheckoutCommand = `git clone --depth 1 https://github.com/aleleba/create-react-ssr ${repoName}`;

View File

@ -1,6 +1,6 @@
{ {
"name": "@aleleba/create-react-ssr", "name": "@aleleba/create-react-ssr",
"version": "3.0.47", "version": "3.0.48",
"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",