-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build pkg, public projects, logout, mime detect, start wizard, readme
- Loading branch information
Jes
committed
May 26, 2018
1 parent
be93f23
commit 4aa47ff
Showing
14 changed files
with
205 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ package-lock.json | |
node_modules | ||
projects.json | ||
sessions | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
const ft = require('file-type'); | ||
const isBinary = require('is-binary'); | ||
const mt = require('mime-types'); | ||
|
||
const {promisify} = require('./helpers'); | ||
|
||
module.exports = (name) => | ||
promisify(fs.stat)(name) | ||
.then(stats => Promise.all([ | ||
stats, | ||
new Buffer(Math.min(stats.size, 512)), | ||
!stats.isDirectory() && promisify(fs.open)(name, 'r'), | ||
])) | ||
.then(a => a[2] && promisify(fs.read)(a[2], a[1], 0, a[1].length, null).then(f => a) || a) | ||
.then(a => [a[0], path.parse(name).ext, ft(a[1]), isBinary(a[1].toString()), mt.lookup(path.parse(name).base)]) | ||
.then(a => a.slice(0, 2).concat(a[2] && a[2].mime || a[3] && 'application/octet-stream' || 'text/plain')) | ||
.then(a => ({exts: a[1], mime: a[2], stats: a[0]})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.