Skip to content

Commit

Permalink
fix(cli): fixed conflicting -h option
Browse files Browse the repository at this point in the history
-h option was used for both --path-override --splash-only flags.

BREAKING CHANGE: -h path override usage is dropped. It's replaced with -v shorthand.

fix #263
  • Loading branch information
onderceylan committed May 7, 2020
1 parent 913fd82 commit 3c9c025
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ $ pwa-asset-generator --help
-m --manifest Web app manifest file path to automatically update manifest file with the generated icons
-i --index Index HTML file path to automatically put splash screen and icon meta tags in
-a --path Path prefix to prepend for href links generated for meta tags
-h --path-override Override the path of images used in href/src tags of manifest and HTML files
-v --path-override Override the path of images used in href/src tags of manifest and HTML files
-t --type Image type: png|jpg|jpeg [default: png]
-q --quality Image quality: 0...100 (Only for JPEG) [default: 100]
-h --splash-only Only generate splash screens [default: false]
Expand Down
8 changes: 8 additions & 0 deletions src/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import execa from 'execa';
import constants from './config/constants';

describe('CLI', () => {
test('throws error when input is not provided', async () => {
Expand Down Expand Up @@ -30,4 +31,11 @@ describe('CLI', () => {
}
expect(response.stdout).toMatchSnapshot();
});

test('does not have any conflicting shorthand options', () => {
const flagShorthands = Object.values(constants.FLAGS).map(
(flag) => flag.alias,
);
expect(new Set(flagShorthands).size).toBe(flagShorthands.length);
});
});
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $ pwa-asset-generator --help
-m --manifest Web app manifest file path to automatically update manifest file with the generated icons
-i --index Index HTML file path to automatically put splash screen and icon meta tags in
-a --path Path prefix to prepend for href links generated for meta tags
-h --path-override Override the path of images used in href/src tags of manifest and HTML files
-v --path-override Override the path of images used in href/src tags of manifest and HTML files
-t --type Image type: png|jpg|jpeg [default: png]
-q --quality Image quality: 0...100 (Only for JPEG) [default: 100]
-h --splash-only Only generate splash screens [default: false]
Expand Down
18 changes: 15 additions & 3 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default {
},
pathOverride: {
type: 'string',
alias: 'h',
alias: 'v',
},
opaque: {
type: 'boolean',
Expand Down Expand Up @@ -245,13 +245,25 @@ export default {
/* eslint-disable */
if (orientation === 'portrait') {
return `\
<link rel="apple-touch-startup-image" href="${url}" media="${darkMode ? '(prefers-color-scheme: dark) and ' : ''}(device-width: ${width / scaleFactor}px) and (device-height: ${height / scaleFactor}px) and (-webkit-device-pixel-ratio: ${scaleFactor}) and (orientation: ${orientation})"${xhtml ? ' /' : ''}>
<link rel="apple-touch-startup-image" href="${url}" media="${
darkMode ? '(prefers-color-scheme: dark) and ' : ''
}(device-width: ${width / scaleFactor}px) and (device-height: ${
height / scaleFactor
}px) and (-webkit-device-pixel-ratio: ${scaleFactor}) and (orientation: ${orientation})"${
xhtml ? ' /' : ''
}>
`;
}

// As weird as it gets, Apple expects same device width and height values from portrait orientation, for landscape
return `\
<link rel="apple-touch-startup-image" href="${url}" media="${darkMode ? '(prefers-color-scheme: dark) and ' : ''}(device-width: ${height / scaleFactor}px) and (device-height: ${width / scaleFactor}px) and (-webkit-device-pixel-ratio: ${scaleFactor}) and (orientation: ${orientation})"${xhtml ? ' /' : ''}>
<link rel="apple-touch-startup-image" href="${url}" media="${
darkMode ? '(prefers-color-scheme: dark) and ' : ''
}(device-width: ${height / scaleFactor}px) and (device-height: ${
width / scaleFactor
}px) and (-webkit-device-pixel-ratio: ${scaleFactor}) and (orientation: ${orientation})"${
xhtml ? ' /' : ''
}>
`;
/* eslint-enable */
},
Expand Down

0 comments on commit 3c9c025

Please sign in to comment.