Socket
Socket
Sign inDemoInstall

file-prompt

Package Overview
Dependencies
250
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.1.3

2

lib/app.js

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

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function readDir(e,t){var r={},n=new _minimatch2["default"].Minimatch(t);return _fs2["default"].readdirSync(e).filter(n.match,n).forEach(function(t){var n=_path2["default"].basename(t,"_page.js");r[n]=require(_path2["default"].resolve(__dirname,e,t))["default"]}),r}function selectCurrentPage(e){return e.getState().currentPage}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(exports,"__esModule",{value:!0});var _component=require("./component"),_component2=_interopRequireDefault(_component),_fs=require("fs"),_fs2=_interopRequireDefault(_fs),_minimatch=require("minimatch"),_minimatch2=_interopRequireDefault(_minimatch),_path=require("path"),_path2=_interopRequireDefault(_path),_reducers=require("./reducers"),_reducers2=_interopRequireDefault(_reducers),_redux=require("redux"),_actions=require("./actions"),App=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e));return r.store=(0,_redux.createStore)(_reducers2["default"],{config:{base:r.props.base},files:[],glob:r.props.glob,currentPage:{name:"index",props:{glob:r.props.glob},isNavigating:!1}}),r}return _inherits(t,e),_createClass(t,[{key:"getDefaultProps",value:function(){return{base:process.cwd(),filter:"**/*.js",stdin:process.stdin,stdout:process.stdout}}},{key:"getInitialState",value:function(){return{pageName:null,pageProps:null}}},{key:"componentWillMount",value:function(){var e=this,t=selectCurrentPage(this.store);this.once("complete",function(){e.componentWillUnmount()},this),this.once("error",function(){e.componentWillUnmount()},this),this.setState({pageName:t.name,pageProps:t.props})}},{key:"componentDidMount",value:function(){var e=this;this.unsubscribe=this.store.subscribe(function(){var t=selectCurrentPage(e.store);t.isNavigating&&(e.setState({pageName:t.name,pageProps:t.props}),_component2["default"].display(e),e.store.dispatch((0,_actions.navigateComplete)()))})}},{key:"componentWillUnmount",value:function(){this.off(),this.unsubscribe()}},{key:"renderPage",value:function(){var e={app:this,store:this.store,stdin:this.props.stdin,stdout:this.props.stdout};if(!t.PAGES.hasOwnProperty(this.state.pageName))throw new Error("App: Page does not exist “"+this.state.pageName+"”.");return this.state.pageProps&&Object.assign(e,this.state.pageProps),new t.PAGES[this.state.pageName](e).render()}},{key:"render",value:function(){return this.renderPage()}}]),t}(_component2["default"]);App.PAGES=readDir(_path2["default"].join(__dirname,"pages"),"*_page.js"),exports["default"]=App;
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function readDir(e,t){var r={};return Array.isArray(t)||(t=[t]),_fs2["default"].readdirSync(e).filter(function(e){return(0,_minimatchAll2["default"])(e,t)}).forEach(function(t){var n=_path2["default"].basename(t,"_page.js");r[n]=require(_path2["default"].resolve(__dirname,e,t))["default"]}),r}function selectCurrentPage(e){return e.getState().currentPage}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(exports,"__esModule",{value:!0});var _component=require("./component"),_component2=_interopRequireDefault(_component),_fs=require("fs"),_fs2=_interopRequireDefault(_fs),_minimatchAll=require("minimatch-all"),_minimatchAll2=_interopRequireDefault(_minimatchAll),_path=require("path"),_path2=_interopRequireDefault(_path),_reducers=require("./reducers"),_reducers2=_interopRequireDefault(_reducers),_redux=require("redux"),_actions=require("./actions"),App=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e));return r.store=(0,_redux.createStore)(_reducers2["default"],{config:{base:r.props.base},files:[],glob:r.props.glob,currentPage:{name:"index",props:{glob:r.props.glob},isNavigating:!1}}),r}return _inherits(t,e),_createClass(t,[{key:"getDefaultProps",value:function(){return{base:process.cwd(),filter:"**/*.js",stdin:process.stdin,stdout:process.stdout}}},{key:"getInitialState",value:function(){return{pageName:null,pageProps:null}}},{key:"componentWillMount",value:function(){var e=this,t=selectCurrentPage(this.store);this.once("complete",function(){e.componentWillUnmount()},this),this.once("error",function(){e.componentWillUnmount()},this),this.setState({pageName:t.name,pageProps:t.props})}},{key:"componentDidMount",value:function(){var e=this;this.unsubscribe=this.store.subscribe(function(){var t=selectCurrentPage(e.store);t.isNavigating&&(e.setState({pageName:t.name,pageProps:t.props}),_component2["default"].display(e),e.store.dispatch((0,_actions.navigateComplete)()))})}},{key:"componentWillUnmount",value:function(){this.off(),this.unsubscribe()}},{key:"renderPage",value:function(){var e={app:this,store:this.store,stdin:this.props.stdin,stdout:this.props.stdout};if(!t.PAGES.hasOwnProperty(this.state.pageName))throw new Error("App: Page does not exist “"+this.state.pageName+"”.");return this.state.pageProps&&Object.assign(e,this.state.pageProps),new t.PAGES[this.state.pageName](e).render()}},{key:"render",value:function(){return this.renderPage()}}]),t}(_component2["default"]);App.PAGES=readDir(_path2["default"].join(__dirname,"pages"),"*_page.js"),exports["default"]=App;

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

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(exports,"__esModule",{value:!0});var _chalk=require("chalk"),_chalk2=_interopRequireDefault(_chalk),_base_dispatcher=require("../streams/base_dispatcher"),_base_dispatcher2=_interopRequireDefault(_base_dispatcher),_menu_transform=require("../streams/menu_transform"),_menu_transform2=_interopRequireDefault(_menu_transform),_minimatch=require("minimatch"),_minimatch2=_interopRequireDefault(_minimatch),_page=require("../page"),_page2=_interopRequireDefault(_page),_path=require("path"),_path2=_interopRequireDefault(_path),_prompt=require("../prompt"),_prompt2=_interopRequireDefault(_prompt),_queries_transform=require("../streams/queries_transform"),_queries_transform2=_interopRequireDefault(_queries_transform),_vertical_menu=require("../vertical_menu"),_vertical_menu2=_interopRequireDefault(_vertical_menu),_child_process=require("child_process"),ChangedPage=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e));return r.question="Add files",r.menu=new _vertical_menu2["default"]({canUnselect:!0,acceptsMany:!0,stdin:r.props.stdin,stdout:r.props.stdout,app:r.props.app}),r.prompt=new _prompt2["default"]({stdin:r.props.stdin,stdout:r.props.stdout}),r}return _inherits(t,e),_createClass(t,[{key:"getInitialState",value:function(){return{files:this.getFiles(this.getGlob())}}},{key:"createOptionsFrom",value:function(e){var t=this.select("files"),r=this.getBasedir();return e.map(function(e,n){return{id:n+1,label:_path2["default"].relative(r,e),name:e,value:e,isSelected:t.indexOf(e)>-1}})||[]}},{key:"getFiles",value:function(e){var t=this.getBasedir(),r=(0,_child_process.execSync)("git diff --name-only"),n=r.toString().split("\n"),i=new _minimatch2["default"].Minimatch(e);return n.length?n.map(function(e){return _path2["default"].resolve(e)}).filter(function(e){return i.match(e)&&e.indexOf(t)>-1}):[]}},{key:"showPrompt",value:function(){return 0===this.menu.options().length?(process.stderr.write(_chalk2["default"].bold.red("No files have been changed since last git commit.\n")),this.navigate("index")):this.prompt.beckon(this.question).pipe(new _queries_transform2["default"]).pipe(new _menu_transform2["default"]({choices:this.menu.options()})).pipe(new _base_dispatcher2["default"]({store:this.props.store})).then(this.reprompt)}},{key:"renderMenu",value:function(){return this.menu.setOptions(this.createOptionsFrom(this.state.files)),this.menu.render()}},{key:"renderPrompt",value:function(){return this.showPrompt}}]),t}(_page2["default"]);exports["default"]=ChangedPage;
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}();Object.defineProperty(exports,"__esModule",{value:!0});var _chalk=require("chalk"),_chalk2=_interopRequireDefault(_chalk),_base_dispatcher=require("../streams/base_dispatcher"),_base_dispatcher2=_interopRequireDefault(_base_dispatcher),_menu_transform=require("../streams/menu_transform"),_menu_transform2=_interopRequireDefault(_menu_transform),_minimatchAll=require("minimatch-all"),_minimatchAll2=_interopRequireDefault(_minimatchAll),_page=require("../page"),_page2=_interopRequireDefault(_page),_path=require("path"),_path2=_interopRequireDefault(_path),_prompt=require("../prompt"),_prompt2=_interopRequireDefault(_prompt),_queries_transform=require("../streams/queries_transform"),_queries_transform2=_interopRequireDefault(_queries_transform),_vertical_menu=require("../vertical_menu"),_vertical_menu2=_interopRequireDefault(_vertical_menu),_child_process=require("child_process"),ChangedPage=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e));return r.question="Add files",r.menu=new _vertical_menu2["default"]({canUnselect:!0,acceptsMany:!0,stdin:r.props.stdin,stdout:r.props.stdout,app:r.props.app}),r.prompt=new _prompt2["default"]({stdin:r.props.stdin,stdout:r.props.stdout}),r}return _inherits(t,e),_createClass(t,[{key:"getInitialState",value:function(){return{files:this.getFiles(this.getGlob())}}},{key:"createOptionsFrom",value:function(e){var t=this.select("files"),r=this.getBasedir();return e.map(function(e,n){return{id:n+1,label:_path2["default"].relative(r,e),name:e,value:e,isSelected:t.indexOf(e)>-1}})||[]}},{key:"getFiles",value:function(e){var t=this.getBasedir(),r=(0,_child_process.execSync)("git diff --name-only"),n=r.toString().split("\n");return Array.isArray(e)||(e=[e]),n.length?n.map(function(e){return _path2["default"].resolve(e)}).filter(function(r){return(0,_minimatchAll2["default"])(r,e)&&r.indexOf(t)>-1}):[]}},{key:"showPrompt",value:function(){return 0===this.menu.options().length?(process.stderr.write(_chalk2["default"].bold.red("No files have been changed since last git commit.\n")),this.navigate("index")):this.prompt.beckon(this.question).pipe(new _queries_transform2["default"]).pipe(new _menu_transform2["default"]({choices:this.menu.options()})).pipe(new _base_dispatcher2["default"]({store:this.props.store})).then(this.reprompt)}},{key:"renderMenu",value:function(){return this.menu.setOptions(this.createOptionsFrom(this.state.files)),this.menu.render()}},{key:"renderPrompt",value:function(){return this.showPrompt}}]),t}(_page2["default"]);exports["default"]=ChangedPage;

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

"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();Object.defineProperty(exports,"__esModule",{value:!0});var _chalk=require("chalk"),_chalk2=_interopRequireDefault(_chalk),_fs=require("fs"),_fs2=_interopRequireDefault(_fs),_base_dispatcher=require("../streams/base_dispatcher"),_base_dispatcher2=_interopRequireDefault(_base_dispatcher),_generic_transform=require("../streams/generic_transform"),_generic_transform2=_interopRequireDefault(_generic_transform),_menu_transform=require("../streams/menu_transform"),_menu_transform2=_interopRequireDefault(_menu_transform),_page=require("../page"),_page2=_interopRequireDefault(_page),_path=require("path"),_path2=_interopRequireDefault(_path),_prompt=require("../prompt"),_prompt2=_interopRequireDefault(_prompt),_queries_transform=require("../streams/queries_transform"),_queries_transform2=_interopRequireDefault(_queries_transform),_vertical_menu=require("../vertical_menu"),_vertical_menu2=_interopRequireDefault(_vertical_menu),_minimatch=require("minimatch"),DirectoriesPage=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e));return r.question="Add files or enter directory",r.menu=new _vertical_menu2["default"]({canUnselect:!0,acceptsMany:!0,stdin:r.props.stdin,stdout:r.props.stdout,app:r.props.app}),r.prompt=new _prompt2["default"]({stdin:r.props.stdin,stdout:r.props.stdout}),r}return _inherits(t,e),_createClass(t,[{key:"getInitialState",value:function(){return{selected:[],targetDir:null}}},{key:"getFiles",value:function(e,t){var r=this.select("config.base"),i=t===r,n=this.select("files"),a=[],s=[],u=new _minimatch.Minimatch(e);return a=_fs2["default"].readdirSync(t),a=a.map(function(e){return _path2["default"].join(t,e)}).filter(function(e){var t=_fs2["default"].statSync(e);return t.isDirectory()?(s.push(e),!0):u.match(e)}).map(function(e,r){var a=_path2["default"].relative(t,e),u=s.indexOf(e)>-1;return u&&(a+="/"),{id:i?r+1:r+2,name:a,value:e,isSelected:n.indexOf(e)>-1,label:u?_chalk2["default"].bold(a):a}}),t!==r&&a.unshift({id:1,name:"..",value:_path2["default"].resolve(t,".."),label:_chalk2["default"].bold("..")}),a}},{key:"showPrompt",value:function(){return this.prompt.beckon(this.question).pipe(new _queries_transform2["default"]).pipe(new _menu_transform2["default"]({choices:this.menu.options()})).pipe(new _generic_transform2["default"](this.processFile.bind(this))).pipe(new _base_dispatcher2["default"]({store:this.props.store,route:this.route})).then(this.reprompt)}},{key:"processFile",value:function(e,t){var r=null,i=t.data,n=t.params,a=i.value,s=void 0;return"file"!==t.type?void e.push(t):(s=_fs2["default"].statSync(a),s.isDirectory()&&(r=a,t.type="directory"),r&&1===n.queryCount&&!this.state.targetDir&&"single"===i.type&&(this.state.targetDir=r),void e.push(t))}},{key:"route",value:function(){return this.state.targetDir?(this.navigate("directories",{base:this.state.targetDir}),!0):void 0}},{key:"renderMenu",value:function(){return this.menu.setOptions(this.getFiles(this.getGlob(),this.getBasedir())),this.menu.render()}},{key:"renderPrompt",value:function(){return this.showPrompt}}]),t}(_page2["default"]);exports["default"]=DirectoriesPage;
"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var _createClass=function(){function e(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,r,i){return r&&e(t.prototype,r),i&&e(t,i),t}}();Object.defineProperty(exports,"__esModule",{value:!0});var _chalk=require("chalk"),_chalk2=_interopRequireDefault(_chalk),_fs=require("fs"),_fs2=_interopRequireDefault(_fs),_base_dispatcher=require("../streams/base_dispatcher"),_base_dispatcher2=_interopRequireDefault(_base_dispatcher),_generic_transform=require("../streams/generic_transform"),_generic_transform2=_interopRequireDefault(_generic_transform),_menu_transform=require("../streams/menu_transform"),_menu_transform2=_interopRequireDefault(_menu_transform),_minimatchAll=require("minimatch-all"),_minimatchAll2=_interopRequireDefault(_minimatchAll),_page=require("../page"),_page2=_interopRequireDefault(_page),_path=require("path"),_path2=_interopRequireDefault(_path),_prompt=require("../prompt"),_prompt2=_interopRequireDefault(_prompt),_queries_transform=require("../streams/queries_transform"),_queries_transform2=_interopRequireDefault(_queries_transform),_vertical_menu=require("../vertical_menu"),_vertical_menu2=_interopRequireDefault(_vertical_menu),DirectoriesPage=function(e){function t(e){_classCallCheck(this,t);var r=_possibleConstructorReturn(this,Object.getPrototypeOf(t).call(this,e));return r.question="Add files or enter directory",r.menu=new _vertical_menu2["default"]({canUnselect:!0,acceptsMany:!0,stdin:r.props.stdin,stdout:r.props.stdout,app:r.props.app}),r.prompt=new _prompt2["default"]({stdin:r.props.stdin,stdout:r.props.stdout}),r}return _inherits(t,e),_createClass(t,[{key:"getInitialState",value:function(){return{selected:[],targetDir:null}}},{key:"getFiles",value:function(e,t){var r=this.select("config.base"),i=t===r,n=this.select("files"),a=[],s=[];return Array.isArray(e)||(e=[e]),a=_fs2["default"].readdirSync(t),a=a.map(function(e){return _path2["default"].join(t,e)}).filter(function(t){var r=_fs2["default"].statSync(t);return r.isDirectory()?(s.push(t),!0):(0,_minimatchAll2["default"])(t,e)}).map(function(e,r){var a=_path2["default"].relative(t,e),u=s.indexOf(e)>-1;return u&&(a+="/"),{id:i?r+1:r+2,name:a,value:e,isSelected:n.indexOf(e)>-1,label:u?_chalk2["default"].bold(a):a}}),t!==r&&a.unshift({id:1,name:"..",value:_path2["default"].resolve(t,".."),label:_chalk2["default"].bold("..")}),a}},{key:"showPrompt",value:function(){return this.prompt.beckon(this.question).pipe(new _queries_transform2["default"]).pipe(new _menu_transform2["default"]({choices:this.menu.options()})).pipe(new _generic_transform2["default"](this.processFile.bind(this))).pipe(new _base_dispatcher2["default"]({store:this.props.store,route:this.route})).then(this.reprompt)}},{key:"processFile",value:function(e,t){var r=null,i=t.data,n=t.params,a=i.value,s=void 0;return"file"!==t.type?void e.push(t):(s=_fs2["default"].statSync(a),s.isDirectory()&&(r=a,t.type="directory"),r&&1===n.queryCount&&!this.state.targetDir&&"single"===i.type&&(this.state.targetDir=r),void e.push(t))}},{key:"route",value:function(){return this.state.targetDir?(this.navigate("directories",{base:this.state.targetDir}),!0):void 0}},{key:"renderMenu",value:function(){return this.menu.setOptions(this.getFiles(this.getGlob(),this.getBasedir())),this.menu.render()}},{key:"renderPrompt",value:function(){return this.showPrompt}}]),t}(_page2["default"]);exports["default"]=DirectoriesPage;
{
"name": "file-prompt",
"version": "1.1.2",
"version": "1.1.3",
"description": "An interactive prompt for selecting files from a directory.",

@@ -37,3 +37,3 @@ "main": "index.js",

"glob-all": "^3.0.1",
"minimatch": "^3.0.0",
"minimatch-all": "^1.0.2",
"redux": "^3.0.4",

@@ -40,0 +40,0 @@ "strip-ansi": "^3.0.0",

import Component from './component';
import fs from 'fs';
import minimatch from 'minimatch';
import minimatch from 'minimatch-all';
import path from 'path';

@@ -18,8 +18,11 @@ import reducers from './reducers';

function readDir (dir, glob) {
let files = {},
mm = new minimatch.Minimatch(glob);
let files = {};
if (!Array.isArray(glob)) glob = [glob];
fs.readdirSync(dir)
// Filter out the ones that don't match the glob
.filter(mm.match, mm)
.filter((file) => {
return minimatch(file, glob);
})
// For each match lets append it to our files object

@@ -26,0 +29,0 @@ .forEach((file) => {

import colors from 'chalk';
import Dispatcher from '../streams/base_dispatcher';
import MenuTransform from '../streams/menu_transform';
import minimatch from 'minimatch';
import minimatch from 'minimatch-all';
import Page from '../page';

@@ -113,5 +113,6 @@ import path from 'path';

output = execSync('git diff --name-only'),
files = output.toString().split('\n'),
mm = new minimatch.Minimatch(pattern);
files = output.toString().split('\n');
if (!Array.isArray(pattern)) pattern = [pattern];
if (!files.length) return [];

@@ -123,3 +124,3 @@

.filter((filename) => {
return mm.match(filename) && filename.indexOf(basedir) > -1;
return minimatch(filename, pattern) && filename.indexOf(basedir) > -1;
});

@@ -126,0 +127,0 @@ }

@@ -6,2 +6,3 @@ import colors from 'chalk';

import MenuTransform from '../streams/menu_transform';
import minimatch from 'minimatch-all';
import Page from '../page';

@@ -12,3 +13,2 @@ import path from 'path';

import VerticalMenu from '../vertical_menu';
import { Minimatch } from 'minimatch';

@@ -95,5 +95,7 @@ /**

files = [],
directories = [],
mm = new Minimatch(glob);
directories = [];
// Force glob to be an array
if (!Array.isArray(glob)) glob = [glob];
files = fs.readdirSync(dir);

@@ -115,3 +117,3 @@

return mm.match(filepath);
return minimatch(filepath, glob);
})

@@ -118,0 +120,0 @@ // Second filter files against

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc