Skip to content

Commit

Permalink
Report an error when using both --offline and new-package
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmengels committed Oct 17, 2023
1 parent 24de02d commit b49d8d1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,22 @@ Otherwise, I recommend you try to gain network access and initialize your config
)
);
}

if (args.offline && subcommand === 'new-package') {
reportErrorAndExit(
new ErrorMessage.CustomError(
'COMMAND REQUIRES NETWORK ACCESS',
wrap(
`I can't use ${chalk.yellow('new-package')} in ${chalk.cyan(
'offline'
)} mode, as I need network access to perform a number of steps.
I recommend you try to gain network access and try again.`,
80
)
)
);
}
}

function parseGitHubAuth(subcommand, gitHubAuth) {
Expand Down
5 changes: 5 additions & 0 deletions test/flags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,8 @@ test('Using both --template and --offline (init)', async () => {
const output = await TestCli.runAndExpectError('init --template jfmengels/elm-review-unused/example --offline');
expect(output).toMatchFile(testName('template-and-offline-init'));
});

test('Using both new-package and --offline', async () => {
const output = await TestCli.runAndExpectError('new-package --offline');
expect(output).toMatchFile(testName('offline-new-package'));
});
7 changes: 7 additions & 0 deletions test/snapshots/flags/offline-new-package.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- COMMAND REQUIRES NETWORK ACCESS ---------------------------------------------

I can't use new-package in offline mode, as I need network access to perform a
number of steps.

I recommend you try to gain network access and try again.

0 comments on commit b49d8d1

Please sign in to comment.