Skip to content

Commit

Permalink
creating fileSystem functions
Browse files Browse the repository at this point in the history
  • Loading branch information
joemay96 committed Jan 18, 2022
1 parent 147ad3d commit fad07ba
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const inquirer = require('inquirer');
const listr = require('listr');
// const ora = require('ora')
const {createManifest} = require("./utils/createManifest");

inquirer
.prompt([
Expand Down Expand Up @@ -41,6 +42,12 @@ inquirer
message: "Default locale: ",
default: "en"
},
{
type: "input",
name: "license",
message: "License: ",
default: "MIT"
},
{
type: "checkbox",
name: "options",
Expand All @@ -55,8 +62,9 @@ inquirer
}
])
.then((answers) => {
console.log(answers)
})
const status = createManifest(answers.name, answers.version, answers.description, answers.manifestVersion, answers.author, answers.locale, answers.license);
console.log(status)
})
.catch((error) => {
if (error.isTtyError) {
// Prompt couldn't be rendered in the current environment
Expand Down
8 changes: 8 additions & 0 deletions utils/createManifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function createManifest(name,version,description, manifestVersion,author,locale, license){
console.log(`Name: ${name}, Version: ${version}, Desc:${description}, ManifestVersion: ${manifestVersion}, Author: ${author}, Default_locale: ${locale}, License: ${license}`)
return 1;
}

module.exports = {
createManifest,
}
42 changes: 42 additions & 0 deletions utils/createStructures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require("fs")

/**
* Function to create a new folder with the given name
* @param {The name of the created folder} folderName
*/
function createDirectory(folderName){
try {
if(!fs.existsSync(folderName)){
fs.mkdirSync(folderName)
}
} catch(err) {
console.log(err)
}
}

/**
* Function to create a new, currently not existing file and injecting input
* @param {name of the created file} name
* @param {The contecxt to be injected into the file} content
*/
function createFile(name, content){
fs.open(name, "w", (err, file) => {
if(err) console.log(`Error creating file ${name} because ${err}`);
// file.
});
}

/**
* Function to append content in a file at a specific place
* @param {Name of the file the content should be appended to} name
* @param {The content that should be appendend in the file} content
*/
function appendContent(name, content) {

}

module.exports = {
createDirectory,
createFile,
appendContent,
}

0 comments on commit fad07ba

Please sign in to comment.