From e141afe098f27b839ecfcfc67e67a718c67f74c1 Mon Sep 17 00:00:00 2001 From: Yiming Li Date: Sat, 21 Aug 2021 14:04:36 +0800 Subject: [PATCH] :sparkles: Feature(error): throw error when no url found in output (#101) * :package: Chore(build): remove all unnecessary files in vsix & don't minify bundle * :sparkles: Feature(error): throw error when no url found in output * :package: Chore(deps): update node_modules when yarn.lock changed * :package: Chore(prepublish): yarn before prepublish build --- .gitignore | 1 + .scripts/update_dependencies.sh | 16 ++++++++++++++++ .vscode/settings.json | 12 +----------- .vscodeignore | 20 ++++++++------------ package.json | 5 +++-- src/vs-picgo/index.ts | 3 +++ webpack.config.js | 4 ++++ 7 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 .scripts/update_dependencies.sh diff --git a/.gitignore b/.gitignore index 6947b41..244665f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ coverage dist tmp assets/test.md +*.zip \ No newline at end of file diff --git a/.scripts/update_dependencies.sh b/.scripts/update_dependencies.sh new file mode 100644 index 0000000..a1c6cd7 --- /dev/null +++ b/.scripts/update_dependencies.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# MIT © Sindre Sorhus - sindresorhus.com +# https://gist.github.com/sindresorhus/7996717 +# https://gist.github.com/GianlucaGuarini/8001627 + +# git hook to run a command after `git pull` if a specified file was changed +# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`. + +changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" + +check_run() { + echo "$changed_files" | grep -E --quiet "$1" && eval "$2" +} + +# run yarn when yarn.lock changed +check_run "yarn.lock" "yarn" diff --git a/.vscode/settings.json b/.vscode/settings.json index 72ca099..92d58ee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,11 +1,5 @@ // Place your settings in this file to overwrite default and user settings. { - "files.exclude": { - "out": false // set this to true to hide the "out" folder with the compiled JS files - }, - "search.exclude": { - "out": true // set this to false to include "out" folder in search results - }, // Turn off tsc task auto detection since we have the necessary tasks as npm scripts "typescript.tsc.autoDetect": "off", "files.insertFinalNewline": true, @@ -35,9 +29,5 @@ "eslint.packageManager": "yarn", "typescript.tsdk": "node_modules\\typescript\\lib", "editor.tabSize": 2, - "cSpell.words": [ - "Mixins", - "picgo", - "vspicgo" - ] + "cSpell.words": ["Mixins", "picgo", "vspicgo"] } diff --git a/.vscodeignore b/.vscodeignore index f47f6b3..b9247f8 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,12 +1,8 @@ -.vscode/** -.vscode-test/** -out/test/** -src/** -.gitignore -**/tsconfig.json -**/.eslintrc.json -**/*.map -**/*.ts -node_modules -out/ -webpack.config.js +** +!dist +!logo.png +!README.md +!CHANGELOG.md +!LICENSE +!package.json +!package.nls.json diff --git a/package.json b/package.json index d0d5837..ab86d45 100644 --- a/package.json +++ b/package.json @@ -291,7 +291,7 @@ } }, "scripts": { - "vscode:prepublish": "webpack --mode production", + "vscode:prepublish": "yarn && webpack --mode production", "compile": "webpack --mode development", "watch": "webpack --mode development --watch", "test": "tsc -p ./ && node ./out/test/run-test.js", @@ -304,7 +304,8 @@ "husky": { "hooks": { "pre-commit": "lint-staged", - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS", + "post-merge": "sh .scripts/update_dependencies.sh" } }, "lint-staged": { diff --git a/src/vs-picgo/index.ts b/src/vs-picgo/index.ts index a19dc55..e115dc5 100644 --- a/src/vs-picgo/index.ts +++ b/src/vs-picgo/index.ts @@ -106,6 +106,9 @@ export default class VSPicgo extends EventEmitter { '' ) urlText = urlText.trim() + if (!urlText) { + throw new Error('no image URL found in the output') + } await this.updateData(ctx.output) } catch (err) { if (err instanceof SyntaxError) { diff --git a/webpack.config.js b/webpack.config.js index 4ed84d8..22f545e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -40,6 +40,10 @@ const config = { } ] }, + optimization: { + // We no not want to minimize our code. + minimize: false + }, plugins: [ // @ts-ignore new CopyPlugin({