-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add linting rules, add synchronous and asynchronous checks and approp…
…riate tests
- Loading branch information
Showing
7 changed files
with
37 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules/* | ||
static/* | ||
build/* | ||
intl/* | ||
locales/* | ||
**/*.min.js |
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,4 @@ | ||
module.exports = { | ||
extends: ['scratch', 'scratch/node','scratch/es6'], | ||
}; | ||
|
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 |
---|---|---|
@@ -1 +1,7 @@ | ||
# scratch-asset-types | ||
|
||
A library for detecting types for Scratch backend services that is optimized for the specific file types that Scratch services depend on. | ||
|
||
### Thanks to file-type | ||
|
||
This library is derived from the more general [file-type](https://www.npmjs.com/package/file-type) npm module. |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,25 @@ | ||
const tap = require('tap'); | ||
const readChunk = require('read-chunk'); | ||
const fileType = require('../../index'); | ||
const typesList = require('../../lib/typeslist'); | ||
|
||
const checkList = [ | ||
'gif', 'jpg', 'json', 'png', 'webp', 'zip']; | ||
|
||
tap.test('check-types', t => { | ||
|
||
checkList.forEach(thisType => { | ||
const buffer = readChunk.sync(`./test/fixtures/test.${thisType}`, 0, 128); | ||
const detectedType = fileType(buffer); | ||
const detectedType = fileType.syncCheck(`./test/fixtures/test.${thisType}`); | ||
t.ok(detectedType); | ||
t.equals(detectedType.ext, typesList[thisType].ext); | ||
t.equals(detectedType.mime, typesList[thisType].mime); | ||
}); | ||
|
||
t.end(); | ||
}); | ||
|
||
checkList.forEach(thisType => fileType.asyncCheck(`./test/fixtures/test.${thisType}`) | ||
.then(result => tap.test('check async results', t => { | ||
t.ok(result); | ||
t.equals(result.ext, typesList[thisType].ext); | ||
t.equals(result.mime, typesList[thisType].mime); | ||
t.end(); | ||
}))); |