Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

genfile

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genfile - npm Package Compare versions

Comparing version 0.0.4 to 0.1.0

CHANGELOG.md

2

dist/genfile.esm.js

@@ -1,1 +0,1 @@

import{pathExists,outputJSON,outputFile}from"fs-extra";import chalk from"chalk";var errorMsg=chalk.bold.red,warnMsg=chalk.bold.keyword("orange"),createMsg=chalk.bold.green,updateMsg=chalk.bold.blue,lightMsg=chalk.bold.magenta,outputContent=function(a,b,c){if("object"==typeof b){outputJSON(a,b,{spaces:2}).then(function(){return console.info(c)}).catch(function(a){return console.error(errorMsg(a))})}else{outputFile(a,b).then(function(){return console.info(c)}).catch(function(a){return console.error(errorMsg(a))})}},genFile=function(a){var b=a.filename,c=a.template,d=a.path,e=void 0===d?"":d,f=a.update,g=e.replace(/(^\/)|(\/$)/g,"");g=g?g+"/"+b:b;pathExists(g,function(a,b){if(!b){outputContent(g,c,createMsg("[create]")+": "+lightMsg(g)+" successfully!")}else{if(f){outputContent(g,c,updateMsg("[update]")+": "+lightMsg(g)+" successfully!")}else{console.info(warnMsg("[warn]")+": "+lightMsg(g)+" already exists!")}}})};export default genFile;
import{pathExists,outputJSON,outputFile}from"fs-extra";import chalk from"chalk";function __awaiter(a,b,c,d){return new(c||(c=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(a){f(a)}}function h(a){try{i(d["throw"](a))}catch(a){f(a)}}function i(a){a.done?e(a.value):new c(function(b){b(a.value)}).then(g,h)}i((d=d.apply(a,b||[])).next())})}function __generator(a,b){var e={label:0,sent:function(){if(1&j[0])throw j[1];return j[1]},trys:[],ops:[]},h,i,j,k;return k={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(k[Symbol.iterator]=function(){return this}),k;function c(a){return function(b){return d([a,b])}}function d(c){if(h)throw new TypeError("Generator is already executing.");while(e)try{if(h=1,i&&(j=2&c[0]?i["return"]:c[0]?i["throw"]||((j=i["return"])&&j.call(i),0):i.next)&&!(j=j.call(i,c[1])).done)return j;if(i=0,j)c=[2&c[0],j.value];switch(c[0]){case 0:case 1:j=c;break;case 4:e.label++;return{value:c[1],done:!1};case 5:e.label++;i=c[1];c=[0];continue;case 7:c=e.ops.pop();e.trys.pop();continue;default:if(!(j=e.trys,j=0<j.length&&j[j.length-1])&&(6===c[0]||2===c[0])){e=0;continue}if(3===c[0]&&(!j||c[1]>j[0]&&c[1]<j[3])){e.label=c[1];break}if(6===c[0]&&e.label<j[1]){e.label=j[1];j=c;break}if(j&&e.label<j[2]){e.label=j[2];e.ops.push(c);break}if(j[2])e.ops.pop();e.trys.pop();continue;}c=b.call(a,e)}catch(a){c=[6,a];i=0}finally{h=j=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var log=console.info,errorMsg=chalk.bold.red,warnMsg=chalk.bold.keyword("orange"),createMsg=chalk.bold.green,updateMsg=chalk.bold.blue,lightMsg=chalk.bold.magenta,outputContent=function(a,b,c){if("object"==typeof b){return outputJSON(a,b,{spaces:2}).then(function(){return log(c)}).catch(function(a){return console.error(errorMsg(a))})}else{return outputFile(a,b).then(function(){return log(c)}).catch(function(a){return console.error(errorMsg(a))})}},genFile=function(a){var b=a.filename,c=a.template,d=a.path,e=void 0===d?"":d,f=a.update,g=e.replace(/(^\/)|(\/$)/g,"");g=g?g+"/"+b:b;return new Promise(function(a){pathExists(g,function(b,d){return __awaiter(void 0,void 0,void 0,function(){return __generator(this,function(b){switch(b.label){case 0:if(!!d)return[3,2];return[4,outputContent(g,c,createMsg("[create]")+": "+lightMsg(g))];case 1:b.sent();a("create");return[3,5];case 2:if(!f)return[3,4];return[4,outputContent(g,c,updateMsg("[update]")+": "+lightMsg(g))];case 3:b.sent();a("update");return[3,5];case 4:log(warnMsg("[exist]")+": "+lightMsg(g));a("exist");b.label=5;case 5:return[2];}})})})})};export default genFile;

@@ -1,1 +0,1 @@

(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b(require("fs-extra"),require("chalk")):"function"==typeof define&&define.amd?define(["fs-extra","chalk"],b):(a=a||self,a.genfile=b(a.fsExtra,a.chalk))})(this,function(a,b){'use strict';b=b&&b.hasOwnProperty("default")?b["default"]:b;var c=b.bold.red,d=b.bold.keyword("orange"),e=b.bold.green,f=b.bold.blue,g=b.bold.magenta,h=function(b,d,e){if("object"==typeof d){a.outputJSON(b,d,{spaces:2}).then(function(){return console.info(e)}).catch(function(a){return console.error(c(a))})}else{a.outputFile(b,d).then(function(){return console.info(e)}).catch(function(a){return console.error(c(a))})}};return function(b){var c=b.filename,i=b.template,j=b.path,k=void 0===j?"":j,l=b.update,m=k.replace(/(^\/)|(\/$)/g,"");m=m?m+"/"+c:c;a.pathExists(m,function(a,b){if(!b){h(m,i,e("[create]")+": "+g(m)+" successfully!")}else{if(l){h(m,i,f("[update]")+": "+g(m)+" successfully!")}else{console.info(d("[warn]")+": "+g(m)+" already exists!")}}})}});
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b(require("fs-extra"),require("chalk")):"function"==typeof define&&define.amd?define(["fs-extra","chalk"],b):(a=a||self,a.genfile=b(a.fsExtra,a.chalk))})(this,function(a,b){'use strict';b=b&&b.hasOwnProperty("default")?b["default"]:b;function c(a,b,c,d){return new(c||(c=Promise))(function(e,f){function g(a){try{i(d.next(a))}catch(a){f(a)}}function h(a){try{i(d["throw"](a))}catch(a){f(a)}}function i(a){a.done?e(a.value):new c(function(b){b(a.value)}).then(g,h)}i((d=d.apply(a,b||[])).next())})}function d(a,b){var e={label:0,sent:function(){if(1&j[0])throw j[1];return j[1]},trys:[],ops:[]},h,i,j,k;return k={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(k[Symbol.iterator]=function(){return this}),k;function c(a){return function(b){return d([a,b])}}function d(c){if(h)throw new TypeError("Generator is already executing.");while(e)try{if(h=1,i&&(j=2&c[0]?i["return"]:c[0]?i["throw"]||((j=i["return"])&&j.call(i),0):i.next)&&!(j=j.call(i,c[1])).done)return j;if(i=0,j)c=[2&c[0],j.value];switch(c[0]){case 0:case 1:j=c;break;case 4:e.label++;return{value:c[1],done:!1};case 5:e.label++;i=c[1];c=[0];continue;case 7:c=e.ops.pop();e.trys.pop();continue;default:if(!(j=e.trys,j=0<j.length&&j[j.length-1])&&(6===c[0]||2===c[0])){e=0;continue}if(3===c[0]&&(!j||c[1]>j[0]&&c[1]<j[3])){e.label=c[1];break}if(6===c[0]&&e.label<j[1]){e.label=j[1];j=c;break}if(j&&e.label<j[2]){e.label=j[2];e.ops.push(c);break}if(j[2])e.ops.pop();e.trys.pop();continue;}c=b.call(a,e)}catch(a){c=[6,a];i=0}finally{h=j=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}var e=console.info,f=b.bold.red,g=b.bold.keyword("orange"),h=b.bold.green,i=b.bold.blue,j=b.bold.magenta,k=function(b,c,d){if("object"==typeof c){return a.outputJSON(b,c,{spaces:2}).then(function(){return e(d)}).catch(function(a){return console.error(f(a))})}else{return a.outputFile(b,c).then(function(){return e(d)}).catch(function(a){return console.error(f(a))})}};return function(b){var f=b.filename,l=b.template,m=b.path,n=void 0===m?"":m,o=b.update,p=n.replace(/(^\/)|(\/$)/g,"");p=p?p+"/"+f:f;return new Promise(function(b){a.pathExists(p,function(a,f){return c(void 0,void 0,void 0,function(){return d(this,function(a){switch(a.label){case 0:if(!!f)return[3,2];return[4,k(p,l,h("[create]")+": "+j(p))];case 1:a.sent();b("create");return[3,5];case 2:if(!o)return[3,4];return[4,k(p,l,i("[update]")+": "+j(p))];case 3:a.sent();b("update");return[3,5];case 4:e(g("[exist]")+": "+j(p));b("exist");a.label=5;case 5:return[2];}})})})})}});

@@ -7,3 +7,3 @@ export interface IGenFile {

}
declare const genFile: ({ filename, template, path, update }: IGenFile) => void;
declare const genFile: ({ filename, template, path, update }: IGenFile) => Promise<string>;
export default genFile;
{
"name": "genfile",
"version": "0.0.4",
"version": "0.1.0",
"description": "Generate file",

@@ -14,7 +14,8 @@ "main": "dist/genfile.umd.js",

"scripts": {
"build": "rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src",
"test": "rimraf ./test/file && ava --verbose",
"lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'",
"prebuild": "rimraf dist docs",
"build": "rollup -c rollup.config.ts && typedoc --out docs --target es6 --theme minimal --mode file src",
"dev": "rollup -c rollup.config.ts",
"dev:w": "yarn dev -w"
"dev:watch": "yarn dev -w"
},

@@ -27,3 +28,4 @@ "keywords": [

"generate-file",
"genfile"
"genfile",
"promise"
],

@@ -35,2 +37,3 @@ "license": "MIT",

"devDependencies": {
"ava": "^2.4.0",
"lodash.camelcase": "^4.3.0",

@@ -46,3 +49,3 @@ "rimraf": "^2.6.3",

"typedoc": "^0.14.2",
"typescript": "^3.3.4000"
"typescript": "^3.3.4"
},

@@ -49,0 +52,0 @@ "dependencies": {

@@ -27,2 +27,12 @@ # genFile

Promise.all([
genFile({
filename: './test/file/a.txt',
template: 'test a',
}),
genFile({
filename: './test/file/b.txt',
template: 'test b',
})
]).then(state => console.info(state));
```

@@ -29,0 +39,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc