Skip to content

Commit

Permalink
feat(fs): add isExecutableFile utility
Browse files Browse the repository at this point in the history
  • Loading branch information
imhoffd committed Mar 3, 2019
1 parent 638cf61 commit 53d9626
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/@ionic/utils-fs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ export async function pathExecutable(filePath: string): Promise<boolean> {
return pathAccessible(filePath, fs.constants.X_OK);
}

export async function isExecutableFile(filePath: string): Promise<boolean> {
const [ stats, executable ] = await Promise.all([safe.stat(filePath), pathExecutable(filePath)]);

return !!stats && (stats.isFile() || stats.isSymbolicLink()) && executable;
}

/**
* Find the base directory based on the path given and a marker file to look for.
*/
Expand Down

0 comments on commit 53d9626

Please sign in to comment.