Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check swSrc for hardcoded injection point in wizard flow #2451

Merged
merged 1 commit into from
Apr 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 0 additions & 20 deletions packages/workbox-cli/src/lib/assert-valid-sw-src.js

This file was deleted.

8 changes: 1 addition & 7 deletions packages/workbox-cli/src/lib/questions/ask-sw-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
const inquirer = require('inquirer');
const ol = require('common-tags').oneLine;

const assertValidSWSrc = require('../assert-valid-sw-src');

// The key used for the question/answer.
const name = 'swSrc';

Expand All @@ -29,9 +27,5 @@ function askQuestion() {

module.exports = async () => {
const answers = await askQuestion();
const swSrc = answers[name].trim();

await assertValidSWSrc(swSrc);

return swSrc;
return answers[name].trim();
};
18 changes: 0 additions & 18 deletions test/workbox-cli/node/lib/questions/ask-sw-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,12 @@ const MODULE_PATH = '../../../../../packages/workbox-cli/src/lib/questions/ask-s
const QUESTION_NAME = 'swSrc';

describe(`[workbox-cli] lib/questions/ask-sw-src.js`, function() {
it(`should reject when the valid SW assertion fails`, async function() {
const injectedError = new Error('injected error');
const askSWSrc = proxyquire(MODULE_PATH, {
'inquirer': {
prompt: () => Promise.resolve({[QUESTION_NAME]: ''}),
},
'../assert-valid-sw-src': () => Promise.reject(injectedError),
});

try {
await askSWSrc();
throw new Error('Unexpected success.');
} catch (error) {
expect(error).to.eql(injectedError);
}
});

it(`should resolve with a valid answer to the question`, async function() {
const expectedAnswer = 'expected answer';
const askSWSrc = proxyquire(MODULE_PATH, {
'inquirer': {
prompt: () => Promise.resolve({[QUESTION_NAME]: expectedAnswer}),
},
'../assert-valid-sw-src': () => Promise.resolve(),
});

const answer = await askSWSrc();
Expand Down