Skip to content

Commit

Permalink
Made it so the command line flow can only be run when calling the scr…
Browse files Browse the repository at this point in the history
…ipt directly
  • Loading branch information
TomikaArome committed Sep 8, 2020
1 parent 861f695 commit 1d598c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ Gets a session token which can be used to regenerate new iksm_session cookies.

Generates an `iksm_session` cookie using a given session_token.

### Functions

Most functions can throw errors. An object with one or two properties is thrown:
```js
{
message: <String>, // A string containing an error message
original: <Error> // The original error usually not generated by the package
}
```

## Disclaimer

A few points to stress:
Expand Down
6 changes: 3 additions & 3 deletions iksm.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const askQuestion = (query) => {
*-------------------*/

const setUserAgent = (uA) => {
if (!uA || uA === '' || /^splatnet2-cookie-node\/[0-9\.]+(.*)$/.test(uA)) {
if (!uA || uA === '' || /^splatnet2-cookie-node\/[0-9.]+(.*)$/.test(uA)) {
throw {
message: 'Invalid User-Agent',
original: uA
Expand Down Expand Up @@ -491,8 +491,8 @@ const getHashFromS2sApi = async (idToken, timestamp) => {

(async () => {

// Check the process.argv array exists
if (!process || !process.argv || !process.argv[0] || !process.argv[1]) { return 0; }
// Check if the script was called directly and hasn't been imported using require()
if (require.main !== module || !process || !process.argv || !process.argv[0] || !process.argv[1]) { return 0; }

try {

Expand Down

0 comments on commit 1d598c0

Please sign in to comment.