Handling file opening (#329)
* Add function to escape a shell argument. * Keep track of the last used window. * Implement support for the open-file event. * The shell escape regex needs parentheses to be captured. * Removed lastWindow and added getLastFocusedWindow method to app * Create window create new session only if no callback passed * Added app.windowCallback to handle open-file before "ready" * Small lint fixes * Differeent open file handling: check if it is directory, and if the file is executale or not * Small fixed and added some comments * Added php-escape-shell module in place of custom escapeShellArgument() * Fixed wrong code and added detailed comment * Aliased php_escapeshellcmd import * Rebased; added error handling in OpenFile * changed string contatenation with template literal * Pinned php-escape-shell dependency * Typo fix * getLastdFocusedWindow now uses Array.prototype.reduce() * Notify users of unexisting path while open file
This commit is contained in:
parent
3198a90823
commit
7e941b0451
9 changed files with 106 additions and 14 deletions
17
lib/utils/file.js
Normal file
17
lib/utils/file.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Based on https://github.com/kevva/executable
|
||||
// Since this module doesn't expose the function to check stat mode only,
|
||||
// his logic is pasted here.
|
||||
// Opened an issue and a pull request about it,
|
||||
// to maybe switch to module in the future:
|
||||
// Issue: https://github.com/kevva/executable/issues/9
|
||||
// PR: https://github.com/kevva/executable/pull/10
|
||||
|
||||
export function isExecutable (fileStat) {
|
||||
if (process.platform === 'win32') return true;
|
||||
|
||||
return Boolean(
|
||||
(fileStat['mode'] & parseInt('0001', 8)) ||
|
||||
(fileStat['mode'] & parseInt('0010', 8)) ||
|
||||
(fileStat['mode'] & parseInt('0100', 8))
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue