clarity-cli
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -34,4 +34,8 @@ "use strict"; | ||
var packageJsonFile = _path2.default.join(projectDirectory, "package.json"); | ||
var mainFile = _path2.default.join(projectDirectory, "src/index.js"); | ||
var testFile = _path2.default.join(projectDirectory, "src/tests/example.js"); | ||
var existingPackageJson = null; | ||
var existingReadme = null; | ||
var existingMain = null; | ||
var existingTest = null; | ||
@@ -43,17 +47,51 @@ if (projectName == null) { | ||
console.log("Creating template...."); | ||
console.log("Checking for existing 'tests/example.js' file."); | ||
_fsExtra2.default.readFile(readmeFile).catch(function () { | ||
_fsExtra2.default.readFile(testFile).catch(function () { | ||
console.log("No 'tests/example.js' found."); | ||
return null; | ||
}).then(function (test) { | ||
existingTest = test; | ||
console.log("Checking for existing 'src/index.js' file."); | ||
return _fsExtra2.default.readFile(mainFile); | ||
}).catch(function () { | ||
console.log("No 'src/index.js' found."); | ||
return null; | ||
}).then(function (main) { | ||
console.log("Checking for existing README.md file."); | ||
existingMain = main; | ||
return _fsExtra2.default.readFile(readmeFile); | ||
}).catch(function () { | ||
console.log("No README.md file found."); | ||
return null; | ||
}).then(function (readme) { | ||
existingReadme = readme; | ||
if (readme == null) { | ||
console.log("Found README.md file."); | ||
} | ||
console.log("Checking for existing package.json."); | ||
return _fsExtra2.default.readJson(packageJsonFile); | ||
}).catch(function () { | ||
console.log("No package.json file found."); | ||
return {}; | ||
}).then(function (json) { | ||
existingPackageJson = json; | ||
return _fsExtra2.default.copy(templateDirectory, projectDirectory); | ||
}).then(function () { | ||
console.log("Modifying package.json..."); | ||
return _fsExtra2.default.readJson(packageJsonFile); | ||
}).then(function (packageJson) { | ||
var newPackageJson = Object.assign({ name: projectName }, packageJson, existingPackageJson); | ||
@@ -64,9 +102,32 @@ | ||
}).then(function () { | ||
console.log("Saved package.json."); | ||
if (existingReadme != null) { | ||
console.log("Saving README.md file."); | ||
return _fsExtra2.default.writeFile(readmeFile, existingReadme); | ||
} | ||
}).then(function () { | ||
console.log("Saved README.md."); | ||
if (existingMain != null) { | ||
console.log("Saving 'src/index.js'."); | ||
return _fsExtra2.default.writeFile(mainFile, existingMain); | ||
} | ||
}).then(function () { | ||
console.log("Saved 'src/index.js'."); | ||
if (existingTest != null) { | ||
console.log("Saving 'tests/example.js"); | ||
return _fsExtra2.default.writeFile(testFile, existingTest); | ||
} | ||
}).then(function () { | ||
console.log("Saved 'tests/example.js'."); | ||
console.log("Running npm for you, this may take a while..."); | ||
return _childProcessEs6Promise2.default.exec("npm install", { cwd: projectDirectory }); | ||
}).then(function () { | ||
console.log("Locked and loaded, you are ready to go. Happy coding."); | ||
@@ -73,0 +134,0 @@ }); |
{ | ||
"name": "clarity-cli", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Clarity setup for vscode.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -20,4 +20,8 @@ import fs from "fs-extra"; | ||
var packageJsonFile = path.join(projectDirectory, "package.json"); | ||
var mainFile = path.join(projectDirectory, "src/index.js"); | ||
var testFile = path.join(projectDirectory, "src/tests/example.js"); | ||
var existingPackageJson = null; | ||
var existingReadme = null; | ||
var existingMain = null; | ||
var existingTest = null; | ||
@@ -29,17 +33,60 @@ if (projectName == null) { | ||
console.log("Creating template...."); | ||
console.log("Checking for existing 'src/tests/example.js' file."); | ||
fs.readFile(readmeFile).catch(()=>{ | ||
fs.readFile(testFile).catch(() => { | ||
console.log("No 'tests/example.js' found."); | ||
return null; | ||
}).then((test) => { | ||
existingTest = test; | ||
console.log("Checking for existing 'src/index.js' file."); | ||
return fs.readFile(mainFile) | ||
}).catch(() => { | ||
console.log("No 'src/index.js' found."); | ||
return null; | ||
}).then((main) => { | ||
console.log("Checking for existing README.md file."); | ||
existingMain = main; | ||
return fs.readFile(readmeFile); | ||
}).catch(() => { | ||
console.log("No README.md file found."); | ||
return null; | ||
}).then((readme) => { | ||
existingReadme = readme; | ||
return fs.readJson(packageJsonFile) | ||
if (readme == null) { | ||
console.log("Found README.md file."); | ||
} | ||
console.log("Checking for existing package.json."); | ||
return fs.readJson(packageJsonFile); | ||
}).catch(() => { | ||
console.log("No package.json file found."); | ||
return {}; | ||
}).then((json) => { | ||
existingPackageJson = json; | ||
return fs.copy(templateDirectory, projectDirectory); | ||
}).then(() => { | ||
console.log("Modifying package.json..."); | ||
return fs.readJson(packageJsonFile); | ||
}).then((packageJson) => { | ||
var newPackageJson = Object.assign({ name: projectName }, packageJson, existingPackageJson); | ||
@@ -49,13 +96,42 @@ | ||
return fs.writeJson(packageJsonFile, newPackageJson); | ||
}).then(()=>{ | ||
if (existingReadme != null){ | ||
}).then(() => { | ||
console.log("Saved package.json."); | ||
if (existingReadme != null) { | ||
console.log("Saving README.md file."); | ||
return fs.writeFile(readmeFile, existingReadme); | ||
} | ||
}).then(() => { | ||
console.log("Saved README.md."); | ||
if (existingMain != null) { | ||
console.log("Saving 'src/index.js'."); | ||
return fs.writeFile(mainFile, existingMain); | ||
} | ||
}).then(() => { | ||
console.log("Saved 'src/index.js'."); | ||
if (existingTest != null) { | ||
console.log("Saving 'src/tests/example.js"); | ||
return fs.writeFile(testFile, existingTest); | ||
} | ||
}).then(() => { | ||
console.log("Saved 'src/tests/example.js'."); | ||
console.log("Running npm for you, this may take a while..."); | ||
return childProcess.exec("npm install", { cwd: projectDirectory }); | ||
}).then(() => { | ||
console.log("Locked and loaded, you are ready to go. Happy coding."); | ||
}); | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63772
62
1212