Skip to content

Commit

Permalink
class not fund returns null
Browse files Browse the repository at this point in the history
  • Loading branch information
epomatti committed Aug 3, 2020
1 parent 5bf0bb1 commit d546ba1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
19 changes: 1 addition & 18 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: yolo-coords

on:
Expand Down Expand Up @@ -30,18 +27,4 @@ jobs:
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

publish-gpr:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
3 changes: 2 additions & 1 deletion __tests__/index.test..js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ test('test coordinates 16', () => {
test('Class not found', () => {
const classNumber = '17'
const fileName = 'sample.txt'
expect(() => { coords(classNumber, fileName) }).toThrow(`Did not found class [${classNumber}] in file [${fileName}]`);
const result = coords(classNumber, fileName)
expect(result).toBe(undefined);
});

test('File not found', () => {
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require('fs')
/**
* @param {string} classNumber - The number of the yolo class which contains the coordinates. Example: "16".
* @param {string} txtFilePath - The path to the .txt file with the coordinates.
* @returns {array} The 4 position array with the coordinates. Example: [ '0.235185', '0.381657', '0.396296', '0.727811' ]
* @returns {array} The 4 position array with the coordinates. Example: [ '0.235185', '0.381657', '0.396296', '0.727811' ]. If the class number is not found it will return "undefined"
*/
function coords(classNumber, txtFilePath) {
const txt = fs.readFileSync(txtFilePath).toString()
Expand All @@ -14,7 +14,7 @@ function coords(classNumber, txtFilePath) {
return [values[1], values[2], values[3], values[4]]
}
}
throw `Did not found class [${classNumber}] in file [${txtFilePath}]`
return undefined
}

module.exports = coords;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yolo-coords",
"version": "1.0.2",
"version": "1.0.3",
"description": "A tiny lib to get yolo coordinates (also called labels or annotations) from the .txt file as an array.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit d546ba1

Please sign in to comment.