Comparing version 0.0.1-alpha.3 to 0.0.1-alpha.4
33
index.js
const Module = require('./dist/bas2tap.js') | ||
module.exports = input => { | ||
return new Promise((resolve, reject) => { | ||
Module({ | ||
'input': input, | ||
'resolve': resolve, | ||
'arguments': ['input.bas', 'output.tap', '-a'] | ||
// Prepare args for the bas2tap command. | ||
const args = []; | ||
args.push('input.bas'); | ||
args.push('output.tap'); | ||
args.push('-a'); | ||
// Collect output. | ||
const out = []; | ||
// Call the bas2tap module with data for command. | ||
return new Promise((resolve, reject) => { | ||
Module({ | ||
arguments: args, | ||
input, | ||
out, | ||
resolve, | ||
reject, | ||
print: (text) => { | ||
// console.log(`[stdout] ${text}`); | ||
out.push({type: 'out', text}); | ||
}, | ||
printErr: (text) => { | ||
// console.log(`[stderr] ${text}`); | ||
out.push({type: 'err', text}); | ||
} | ||
}); | ||
}); | ||
}); | ||
} |
{ | ||
"name": "bas2tap", | ||
"version": "0.0.1-alpha.3", | ||
"version": "0.0.1-alpha.4", | ||
"main": "index.js", | ||
"license": "GPL-2.0+", | ||
"author": "Steven Robertson <stever@hey.com>", | ||
"author": "Steve Robertson <stever@hey.com>", | ||
"description": "Emscripten conversion for bas2tap which converts BASIC to a TAP tape file.", | ||
@@ -13,9 +13,9 @@ "keywords": [ | ||
], | ||
"homepage": "https://github.com/stever/bas2tap#readme", | ||
"homepage": "https://github.com/stever/emscripten-bas2tap#readme", | ||
"repository": { | ||
"type" : "git", | ||
"url" : "https://github.com/stever/bas2tap.git" | ||
"type": "git", | ||
"url": "https://github.com/stever/emscripten-bas2tap.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/stever/bas2tap/issues" | ||
"url": "https://github.com/stever/emscripten-bas2tap/issues" | ||
}, | ||
@@ -31,15 +31,43 @@ "files": [ | ||
"build": "run-s clean:all build:release clean", | ||
"build:debug": "mkdirp build && cd build && emcmake cmake -DCMAKE_BUILD_TYPE=Debug ../src/ && make && cp-cli bas2tap.js ../dist/bas2tap.js", | ||
"build:release": "mkdirp build && cd build && emcmake cmake -DCMAKE_BUILD_TYPE=Release ../src/ && make && cp-cli bas2tap.js ../dist/bas2tap.js", | ||
"build:debug": "mkdirp build && cd build && emcmake cmake -DCMAKE_BUILD_TYPE=Debug .. && make && cp-cli bas2tap.js ../dist/bas2tap.js", | ||
"build:release": "mkdirp build && cd build && emcmake cmake -DCMAKE_BUILD_TYPE=Release .. && make && cp-cli bas2tap.js ../dist/bas2tap.js", | ||
"clean": "del-cli build", | ||
"clean:all": "del-cli build dist", | ||
"test": "node test/test.js", | ||
"test": "jest --noStackTrace", | ||
"publish-pkg": "npm publish --access public" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.15.7", | ||
"@babel/core": "^7.15.5", | ||
"@babel/plugin-transform-runtime": "^7.15.0", | ||
"@babel/preset-env": "^7.15.6", | ||
"@babel/preset-react": "^7.14.5", | ||
"babel-jest": "^27.2.1", | ||
"cp-cli": "^1.1.2", | ||
"del-cli": "^4.0.1", | ||
"jest": "^27.2.1", | ||
"jest-transform-stub": "^2.0.0", | ||
"mkdirp": "^0.5.1", | ||
"npm-run-all": "^4.1.5" | ||
} | ||
}, | ||
"jest": { | ||
"testEnvironment": "jsdom", | ||
"transform": { | ||
"^.+\\.[t|j]sx?$": "babel-jest", | ||
".+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)(\\?inline)?$": "jest-transform-stub" | ||
}, | ||
"globals": { | ||
"STAGING_ENV": "prod" | ||
} | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"@babel/preset-env", | ||
"@babel/preset-react" | ||
], | ||
"plugins": [ | ||
"@babel/plugin-transform-runtime" | ||
] | ||
}, | ||
"dependencies": {} | ||
} |
@@ -1,5 +0,7 @@ | ||
# emscripten-bas2tap | ||
# bas2tap | ||
Emscripten conversion for bas2tap which converts BASIC to a TAP tape file. | ||
This package converts 'BASIC in an ASCII file' to a TAP tape image file, to be | ||
used in a ZX Spectrum emulator. Both 48K and 128K listings are supported. | ||
used in a ZX Spectrum emulator. | ||
@@ -13,19 +15,30 @@ ## Usage | ||
```javascript | ||
import Module from "bas2tap"; | ||
import bas2tap from "bas2tap"; | ||
export function bas2tap(input) { | ||
return new Promise((resolve, reject) => { | ||
Module({ | ||
'input': input, | ||
'resolve': resolve, | ||
'arguments': ['input.bas', 'output.tap', '-a'] | ||
}); | ||
}); | ||
} | ||
const tap = bas2tap('10 PRINT "Hello"'); | ||
``` | ||
```javascript | ||
const tap = bas2tap('10 PRINT "Hello"'); | ||
## Build library | ||
Note that you need to have the Emscripten SDK installed and available on path. | ||
Install & activate `emsdk` from Emscripten: | ||
```bash | ||
git clone https://github.com/emscripten-core/emsdk.git | ||
cd emsdk/ | ||
git pull | ||
./emsdk install latest | ||
./emsdk activate latest | ||
source ./emsdk_env.sh | ||
``` | ||
Build the library: | ||
```bash | ||
npm install | ||
npm run build | ||
npm run test | ||
``` | ||
## Licenses | ||
@@ -268,3 +281,3 @@ | ||
Clone the repository and run `npm run build` to build the library. You can | ||
then run `npm run test` to test it (check `test.js`). Also, `npm run | ||
then run `npm run test` to test it (check `bas2tap.test.js`). Also, `npm run | ||
build:debug` builds the project without optimizations. |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
282
190738
12
657