forked from debck/File-Creator-CLI
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# This is a combination of 22 commits.
# This is the 1st commit message: Update README.md # This is the commit message debck#2: Added create folder option, fixes (debck#8) (debck#13) * Added create folder option, fixes (debck#8) * Reverted changes to json files to try to not break build * Better add folder option, fixes (debck#8) # This is the commit message debck#3: Update .travis.yml # This is the commit message debck#4: Update README.md # This is the commit message debck#5: Update app.js # This is the commit message debck#6: Update ifdir.js # This is the commit message debck#7: Update question.js # This is the commit message debck#8: Update ifdir.js # This is the commit message debck#9: Update app.js # This is the commit message debck#10: Update question.js # This is the commit message debck#11: Update app.js # This is the commit message debck#12: Update question.js # This is the commit message debck#13: Update app.js # This is the commit message debck#14: Create functions.js # This is the commit message debck#15: Update question.js # This is the commit message debck#16: Update ifdir.js # This is the commit message debck#17: Update create.js # This is the commit message debck#18: Update app.js # This is the commit message debck#19: Update create.js # This is the commit message debck#20: Create sub.js # This is the commit message debck#21: Solves debck#12(Added badges to Readme) (debck#16) * Update README.md * Update README.md * Update README.md * Update README.md # This is the commit message debck#22: Update README.md
- Loading branch information
1 parent
7fa68c5
commit 95bb787
Showing
9 changed files
with
1,846 additions
and
971 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,3 @@ sudo: false | |
language: node_js | ||
node_js: | ||
- 8 | ||
notifications: | ||
webhooks: https://www.travisbuddy.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,4 @@ | ||
#!/usr/bin/env node | ||
const sub = require("./sub.js"); | ||
|
||
const shell = require('shelljs'); | ||
const inquirer = require('inquirer'); | ||
const chalk = require('chalk'); | ||
const header = require('../lib/header'); | ||
const question = require('../lib/question'); | ||
const create = require('../lib/create'); | ||
|
||
const main = async () => { | ||
header.init(); | ||
|
||
const input = await question.questions(); | ||
// console.log(input); | ||
const { filename, extension } = input; | ||
// console.log(filename); | ||
create.create(filename, extension); | ||
|
||
console.log(chalk.blue('File created successfully') + chalk.red('!!!')); | ||
}; | ||
|
||
main(); | ||
sub.main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const inquirer = require("inquirer"); | ||
const chalk = require("chalk"); | ||
const header = require("../lib/header"); | ||
const question = require("../lib/question"); | ||
const create = require("../lib/create"); | ||
const ifdir = require("../lib/ifdir"); | ||
|
||
const func = require("../lib/functions"); | ||
|
||
const main = (exports.main = async () => { | ||
header.init(); | ||
|
||
const result = await ifdir.ask(); | ||
|
||
const { isdir } = result; | ||
|
||
if (isdir === "d") { | ||
const dir_res = await ifdir.getdir(); | ||
const { dirname } = dir_res; | ||
create.createdir(dirname); | ||
|
||
return 0; | ||
} else if (isdir === "f") { | ||
const input = await question.questions(); | ||
// console.log(input); | ||
const { filename, extension } = input; | ||
// console.log(filename); | ||
create.create(filename, extension); | ||
console.log(chalk.blue("File created successfully") + chalk.red("!!!")); | ||
|
||
return 0; | ||
} else if (isdir === "dld") { | ||
func.deletedirec(); | ||
} else if (isdir === "df") { | ||
func.deletefile(); | ||
} else if (isdir === "fs") { | ||
func.filesize(); | ||
} else if (isdir === "rf") { | ||
func.renamefile(); | ||
} else { | ||
// Invalid response in isdir | ||
return 2; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
const shell = require('shelljs'); | ||
const shell = require("shelljs"); | ||
|
||
exports.create = (filename, extension) => { | ||
const filePath = `${process.cwd()}/${filename}.${extension}`; | ||
exports.create = filename => { | ||
const filePath = `${process.cwd()}/${filename}`; | ||
// console.log(filePath); | ||
shell.touch(filePath); | ||
return 0; | ||
}; | ||
|
||
exports.createdir = dirname => { | ||
const path = `${process.cwd()}/${dirname}`; | ||
shell.mkdir(path); | ||
return 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const shell = require("shelljs"); | ||
const question = require("../lib/question"); | ||
const ifdir = require("../lib/ifdir"); | ||
const fs = require("fs"); | ||
|
||
exports.deletefile = async () => { | ||
const input = await question.questions(); | ||
const { filename } = input; | ||
const name = filename; | ||
shell.rm(name); | ||
}; | ||
|
||
exports.deletedirec = async () => { | ||
const dir_res = await ifdir.getdir(); | ||
const { dirname } = dir_res; | ||
shell.rm("-rf", dirname); | ||
}; | ||
|
||
exports.renamefile = async () => { | ||
const input = await question.questions(); | ||
const { filename } = input; | ||
const name = filename; | ||
const rename = await question.rename(); | ||
const { newname } = rename; | ||
|
||
fs.rename(name, newname, function(err) { | ||
if (err) console.log("ERROR: " + err); | ||
}); | ||
}; | ||
exports.filesize = async () => { | ||
const input = await question.questions(); | ||
const { filename } = input; | ||
const name = filename; | ||
|
||
const fileSizeInBytes = fs.statSync(name).size; | ||
console.log(fileSizeInBytes + "Bytes"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const inquirer = require("inquirer"); | ||
|
||
exports.ask = () => { | ||
const question = [ | ||
{ | ||
name: "isdir", | ||
type: "input", | ||
message: | ||
"Type (d/f) to create a Directory/file or (dld/df) to delete a directory/file (rf/fs) to rename file/get file size " | ||
} | ||
]; | ||
|
||
return inquirer.prompt(question); | ||
}; | ||
|
||
exports.getdir = () => { | ||
const getdir = [ | ||
{ | ||
name: "dirname", | ||
type: "input", | ||
message: "Directory name: " | ||
} | ||
]; | ||
|
||
return inquirer.prompt(getdir); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
const inquirer = require('inquirer'); | ||
const inquirer = require("inquirer"); | ||
|
||
exports.questions = () => { | ||
const questions = [ | ||
{ | ||
name: 'filename', | ||
type: 'input', | ||
message: 'Name of file: ', | ||
}, | ||
{ | ||
name: 'extension', | ||
type: 'input', | ||
message: 'Extension: ', | ||
}, | ||
name: "filename", | ||
type: "input", | ||
message: "Name of file (name.extension): " | ||
} | ||
]; | ||
// console.log(inquirer.prompt(questions)); | ||
return inquirer.prompt(questions); | ||
}; | ||
|
||
exports.rename = () => { | ||
const rename = { | ||
name: "newname", | ||
type: "input", | ||
message: "Rename to: " | ||
}; | ||
|
||
return inquirer.prompt(rename); | ||
}; |
Oops, something went wrong.