Skip to content

Commit

Permalink
v1.2.1 has carriage return in bin/cli.js shebang line #144 (#46)
Browse files Browse the repository at this point in the history
* Add test for CLI execution #44

* Set cli.js to be always have lf line endings #44, update files to comply to .editorconfig
  • Loading branch information
m-mohr authored Dec 13, 2021
1 parent e54e42e commit 362d176
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/cli.js text eol=lf
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ Thumbs.db
# Node / npm
.npm
/node_modules/
/package-lock.json
/package-lock.json
2 changes: 1 addition & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('../index.js')()
require('../index.js')()
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,4 @@ async function loadSchema(schemaId) {

module.exports = async config => {
await run(config);
};
};
2 changes: 1 addition & 1 deletion tests/api/collections.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
}
],
"links": []
}
}
2 changes: 1 addition & 1 deletion tests/api/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@

],
"links": []
}
}
10 changes: 10 additions & 0 deletions tests/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const app = require('../index');
const { version } = require('../package.json');
const fs = require('fs/promises');
const { exec } = require("child_process");

let consoleErrSpy, consoleWarnSpy, consoleInfSpy, consoleLogSpy, mockExit;
const initString = `STAC Node Validator v${version}`;
Expand All @@ -20,6 +21,15 @@ beforeEach(() => {
consoleErrSpy = jest.spyOn(console, 'error').mockImplementation();
});

it('Should be executable via shell', done => {
exec("node ./bin/cli.js --version", (error, stdout, stderr) => {
expect(error).toBe(null);
expect(stderr).toBe("");
expect(stdout).toContain(version);
done();
});
});

it('Should print init string', async () => {
await app();

Expand Down
2 changes: 1 addition & 1 deletion tests/example-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"files": ["tests/examples/catalog.json"],
"verbose": true
}
}
2 changes: 1 addition & 1 deletion tests/examples/catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"title": "Example Catalog",
"description": "A minimal example for tests",
"links": []
}
}
2 changes: 1 addition & 1 deletion tests/examples/invalid-catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"type": "Catalog",
"title": "Example Catalog",
"description": "A minimal example for tests"
}
}

0 comments on commit 362d176

Please sign in to comment.