Skip to content

Commit

Permalink
Merge pull request #96 from sharafdin/sharafdin
Browse files Browse the repository at this point in the history
completed fixed the templated name for windows
  • Loading branch information
sharafdin authored Feb 11, 2024
2 parents 7bf159c + 61fdd07 commit 849a14e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion packages/yonode/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "yonode",
"description": "A Web Server Framework for Node.js",
"version": "0.5.3-beta",
"version": "0.5.4-beta",
"author": "Mr Sharafdin",
"license": "MIT",
"main": "./src/index.js",
Expand Down
32 changes: 16 additions & 16 deletions packages/yonode/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';
import path, { basename } from 'path';
import inquirer from 'inquirer';
import './lib/programOptions.js';
import { databaseType } from './lib/prompt/db.js';
Expand All @@ -36,47 +36,47 @@ let cloneDirectory = process.cwd();
export const cloneRepo = (projectName, branchName) => {


let tempProjectName = cloneDirectory.split('/').pop();
let tempProjectName = basename(process.cwd());

if (projectName === '.') {
console.log(`cloning the repository with name ${tempProjectName}`);
}

const gitCloneCommand = `git clone --depth 1 -b ${branchName} https://github.com/sharafdin/yonode.git ${projectName}`

const gitClone = runCommand(gitCloneCommand)
if(!gitClone) process.exit(1);

if (!gitClone) process.exit(1);

if (projectName === '.') {

const packageJsonPath = path.join(cloneDirectory, 'package.json');
const packageJson = fs.readFileSync(packageJsonPath).toString();


const packageJsonData = JSON.parse(packageJson)

packageJsonData['name'] = tempProjectName

fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonData, null, 2));

console.log('\nCongratulations! follow these commands:\n');
console.log(` npm install \n npm start\n`);
console.log(` npm install \n npm start`);
} else {
cloneDirectory = path.join(process.cwd(), projectName);

const packageJsonPath = path.join(cloneDirectory, 'package.json');
const packageJson = fs.readFileSync(packageJsonPath).toString();


const packageJsonData = JSON.parse(packageJson)

packageJsonData['name'] = projectName

fs.writeFileSync(packageJsonPath, JSON.stringify(packageJsonData, null, 2));

console.log('\nCongratulations! follow these commands:\n');
console.log(` cd ${projectName} \n npm install \n npm start\n`);
console.log(` cd ${projectName} \n npm install \n npm start`);
}

process.exit(1);
Expand All @@ -86,7 +86,7 @@ export const cloneRepo = (projectName, branchName) => {

export let projectName = process.argv[2]

if(projectName === '.'){
if (projectName === '.') {
const files = fs.readdirSync(cloneDirectory);

if (files.length) {
Expand Down

0 comments on commit 849a14e

Please sign in to comment.