From 22f7a99e7d29ee0b4a9767551f14c414bc5ffbe8 Mon Sep 17 00:00:00 2001 From: Waldir Pimenta Date: Fri, 9 Jun 2023 13:34:25 +0100 Subject: [PATCH] Add svgo as npm dependency and setup npm script to run it --- .gitignore | 3 +++ README.md | 17 ++++++++++++++--- package.json | 8 +++++++- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..5ab9157c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Don't track the Node.js installation artifacts +/node_modules/ +/package-lock.json diff --git a/README.md b/README.md index 9e749435..795873c3 100644 --- a/README.md +++ b/README.md @@ -55,14 +55,25 @@ npm install --save https://github.com/HatScripts/circle-flags ## Contributing -To contribute, you need to have the latest version of [svgo](https://github.com/svg/svgo) installed. +### Initial setup + +To contribute, you need to have the [Node.js](https://nodejs.org) JavaScript runtime installed, +and the latest version of [svgo](https://github.com/svg/svgo). +Once Node.js is set up, you can run the following command to install `svgo` in the circle-flags project directory: + +```sh +npm install +``` + +### Making changes First, edit the relevant SVG files in the `flags/` directory. -Then run `svgo` to optimize the SVG files: +Then run the `svgo` wrapper script (defined in the `scripts` section of [package.json](./package.json)), +which uses the locally-installed `svgo` executable to optimize the SVG files: ```sh -svgo ./flags --recursive --config=svgo.config.js +npm run svgo ``` Then commit the changes, and submit them as a pull request. diff --git a/package.json b/package.json index 2ac7e91e..d0053cf9 100644 --- a/package.json +++ b/package.json @@ -33,5 +33,11 @@ "bugs": { "url": "https://github.com/HatScripts/circle-flags/issues" }, - "homepage": "https://github.com/HatScripts/circle-flags#readme" + "homepage": "https://github.com/HatScripts/circle-flags#readme", + "devDependencies": { + "svgo": "^3.0.2" + }, + "scripts": { + "svgo": "node_modules/.bin/svgo ./flags --recursive --config=svgo.config.js" + } }