Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
Where is it?
  • Loading branch information
jochemstoel committed Oct 3, 2017
1 parent 4c47767 commit 9532948
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 0 deletions.
Binary file added built/whereis-linux
Binary file not shown.
Binary file added built/whereis-macos
Binary file not shown.
Binary file added built/whereis-win.exe
Binary file not shown.
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "g-whereis",
"version": "0.0.2",
"description": "",
"main": "whereis.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"bin": "whereis.js",
"author": "Jochem Stoel",
"license": "ISC"
}
25 changes: 25 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# whereis
This is a huge sofisticated super complex framework to find in which PATH directory a file is located. It can also be built as an executable. If you want just the function whereis() then open file _whereis.js_ and copy paste it.

## run using regular node
```bash
node whereis.js git.exe
git.exe found in C:\Program Files (x86)\Git\cmd\git.exe

node whereis.js blooperdeefloop
blooperdeefloop found nowhere
```

## build for cli
If you have _pkg_ installed you can build whereis by simply running
```bash
pkg .
```
This will compile a single executable for windows, linux and osx. If you add the location of whereis.exe to PATH then you can simply run this in your command line in any folder:

```bash
whereis node.exe
```

## binaries
I have included a build for windows/linux/osx using Node v8.5.0 but it is generally advised to build things yourself.
Binary file added whereis.ico
Binary file not shown.
39 changes: 39 additions & 0 deletions whereis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/* whereis | find something in PATH */
var fs = require('fs')
var path = require('path')

function find() {
var pathSep = process.platform === 'win32' ? ';' : ':'
var directories = process.env.PATH.split(pathSep)
for (var i = 0; i < directories.length; i++) {
for (var j = 0; j < arguments.length; j++) {
var filename = arguments[j]
var filePath = path.join(directories[i], filename)

if (fs.existsSync(filePath)) {
return [filePath, directories[i]]
}
}
}
return null
}

let that, where, there

if(process.argv.length==3)
that = process.argv[2]
else {
console.log('whereis what?')
process.exit()
}

where = find(that)

if(where==null)
there = 'nowhere'
else
there = `in ${where[0]}`

console.log(
`${that} found ${there}`
)
Binary file added whereis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9532948

Please sign in to comment.