PR-767513: fix npx.

This commit is contained in:
Alejandro Lembke Barrientos 2022-08-05 23:25:33 +00:00
parent dac561b8a7
commit 84120937ac
2 changed files with 73 additions and 71 deletions

View File

@ -24,13 +24,13 @@ const runCommandWithOutput = command => {
}
}
const replaceTextOnFile = async ({
const replaceTextOnFile = ({
file,
textToBeReplaced,
textReplace,
arrOfObjectsBeReplaced
}) => {
await fs.readFile(file, 'utf8', function (err,data) {
fs.readFile(file, 'utf8', function (err,data) {
let result
if (err) {
return console.error(err);
@ -47,7 +47,7 @@ const replaceTextOnFile = async ({
result = data.replace(textToBeReplaced, textReplace).replace(/^\s*[\r\n]/gm, ' ');
}
fs.writeFileSync(file, result, 'utf8', function (err) {
fs.writeFile(file, result, 'utf8', function (err) {
if (err){
return console.error(err);
}
@ -55,6 +55,7 @@ const replaceTextOnFile = async ({
});
}
(async () => {
const repoName = process.argv[2];
const gitCheckoutCommand = `git clone --depth 1 https://github.com/aleleba/create-react-ssr ${repoName}`;
console.log(`Cloning the repository with name ${repoName}`);
@ -84,7 +85,7 @@ console.log(`Installing dependencies for ${repoName}`);
const installedDeps = runCommand(installDepsCommand);
if(!installedDeps) process.exit(-1);
replaceTextOnFile({
await replaceTextOnFile({
file: `./${repoName}/package.json`,
arrOfObjectsBeReplaced: [
{
@ -122,3 +123,4 @@ console.log(`Then you can run: npm start:dev`);
const deleteFolders = isWin ? runCommand(deleteFoldersCommandWindows) : runCommand(deleteFoldersCommand);
if(!deleteFolders) process.exit(-1);
})();

View File

@ -1,6 +1,6 @@
{
"name": "@aleleba/create-react-ssr",
"version": "3.0.44",
"version": "3.0.45",
"description": "Starter Kit of server side render of react",
"bin": "./bin/cli.js",
"main": "src/server/index",