Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JackGruber committed Jan 11, 2024
1 parent ecc9ce8 commit 830c620
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion GENERATOR_DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This documentation describes how to create a plugin, and how to work with the pl
First, install [Yeoman](http://yeoman.io) and generator-joplin using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).

```bash
npm install -g yo
npm install -g yo@4.3.1
npm install -g generator-joplin
```

Expand Down
13 changes: 9 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,24 @@ function validateCategories(categories) {

function validateScreenshots(screenshots) {
if (!screenshots) return null;
// eslint-disable-next-line github/array-foreach -- Old code before rule was applied
screenshots.forEach(screenshot => {
for (const screenshot of screenshots) {
if (!screenshot.src) throw new Error('You must specify a src for each screenshot');

// Avoid attempting to download and verify URL screenshots.
if (screenshot.src.startsWith('https://') || screenshot.src.startsWith('http://')) {
continue;
}

const screenshotType = screenshot.src.split('.').pop();
if (!allPossibleScreenshotsType.includes(screenshotType)) throw new Error(`${screenshotType} is not a valid screenshot type. Valid types are: \n${allPossibleScreenshotsType}\n`);

const screenshotPath = path.resolve(srcDir, screenshot.src);
const screenshotPath = path.resolve(rootDir, screenshot.src);

// Max file size is 1MB
const fileMaxSize = 1024;
const fileSize = fs.statSync(screenshotPath).size / 1024;
if (fileSize > fileMaxSize) throw new Error(`Max screenshot file size is ${fileMaxSize}KB. ${screenshotPath} is ${fileSize}KB`);
});
}
}

function readManifest(manifestPath) {
Expand Down

0 comments on commit 830c620

Please sign in to comment.