mirror of
https://github.com/scratchfoundation/scratch-asset-types.git
synced 2024-11-14 19:15:04 -05:00
works with our existing list of types
This commit is contained in:
parent
31c074aa08
commit
939849d595
11 changed files with 3988 additions and 0 deletions
26
Makefile
Normal file
26
Makefile
Normal file
|
@ -0,0 +1,26 @@
|
|||
ESLINT=./node_modules/.bin/eslint
|
||||
TAP=./node_modules/.bin/tap
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
start:
|
||||
node server.js
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
lint:
|
||||
$(ESLINT) ./*.js
|
||||
$(ESLINT) ./lib/*.js
|
||||
$(ESLINT) ./test/**/*.js
|
||||
|
||||
tap-tests:
|
||||
$(TAP) ./test/{unit,functional,integration}/*.js
|
||||
|
||||
test:
|
||||
@make lint
|
||||
@make tap-tests
|
||||
|
||||
coverage:
|
||||
$(TAP) ./test/{unit,functional,integration}/*.js --coverage --coverage-report=lcov
|
||||
|
||||
.PHONY: start lint test coverage load
|
13
lib/typeslist.js
Normal file
13
lib/typeslist.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
gif: {ext: 'gif', mime: 'image/gif'},
|
||||
jpg: {ext: 'jpg', mime: 'image/jpg'},
|
||||
jpm: {ext: 'jpg', mime: 'image/jpg'},
|
||||
jpx: {ext: 'jpg', mime: 'image/jpg'},
|
||||
jp2: {ext: 'jpg', mime: 'image/jpg'},
|
||||
json: {ext: 'json', mime: 'application/json'},
|
||||
mj2: {ext: 'jpg', mime: 'image/jpg'},
|
||||
png: {ext: 'png', mime: 'image/png'},
|
||||
webp: {ext: 'webp', mime: 'image/webp'},
|
||||
wav: {ext: 'wav', mime: 'audio/x-mav'},
|
||||
zip: {ext: 'zip', mime: 'application/zip'}
|
||||
};
|
3907
package-lock.json
generated
Normal file
3907
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
21
package.json
Normal file
21
package.json
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "scratch-asset-types",
|
||||
"version": "1.0.0",
|
||||
"description": "Data typing discovering and MIME content-type handling across all media types that the Scratch environment expects",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/LLK/scratch-asset-types.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test"
|
||||
},
|
||||
"author": "Massachusetts Institute of Technology",
|
||||
"license": "private",
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^8.0.3",
|
||||
"eslint": "^4.13.1",
|
||||
"eslint-config-scratch": "^5.0.0",
|
||||
"read-chunk": "^2.1.0",
|
||||
"tap": "^11.0.0"
|
||||
}
|
||||
}
|
BIN
test/fixtures/test.gif
vendored
Normal file
BIN
test/fixtures/test.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.6 KiB |
BIN
test/fixtures/test.jpg
vendored
Normal file
BIN
test/fixtures/test.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
1
test/fixtures/test.json
vendored
Normal file
1
test/fixtures/test.json
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{ "json": "I might be JSON" }
|
BIN
test/fixtures/test.png
vendored
Normal file
BIN
test/fixtures/test.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
BIN
test/fixtures/test.webp
vendored
Normal file
BIN
test/fixtures/test.webp
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
test/fixtures/test.zip
vendored
Normal file
BIN
test/fixtures/test.zip
vendored
Normal file
Binary file not shown.
20
test/unit/filetype.js
Normal file
20
test/unit/filetype.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
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);
|
||||
t.ok(detectedType);
|
||||
t.equals(detectedType.ext, typesList[thisType].ext);
|
||||
t.equals(detectedType.mime, typesList[thisType].mime);
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
Loading…
Reference in a new issue