From cc4da9861689e2a2ec9a7602c2b0b0163619a66a Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 12 Apr 2018 12:14:25 +0200 Subject: [PATCH] Fix adding/replacing a grammar (#4097) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Licensed needs a full path now * Add docker installed/running guard * Docker is required for adding/replacing grammars * Use more elegant method Hat-tip to @Alhadis 🎩 --- CONTRIBUTING.md | 4 ++-- script/add-grammar | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 28e427d756..fce3b90c38 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -28,9 +28,9 @@ To run Linguist from the cloned repository: ### Dependencies -Linguist uses the [`charlock_holmes`](https://github.com/brianmario/charlock_holmes) character encoding detection library which in turn uses [ICU](http://site.icu-project.org/), and the libgit2 bindings for Ruby provided by [`rugged`](https://github.com/libgit2/rugged). These components have their own dependencies - `icu4c`, and `cmake` and `pkg-config` respectively - which you may need to install before you can install Linguist. +Linguist uses the [`charlock_holmes`](https://github.com/brianmario/charlock_holmes) character encoding detection library which in turn uses [ICU](http://site.icu-project.org/), and the libgit2 bindings for Ruby provided by [`rugged`](https://github.com/libgit2/rugged). [Docker](https://www.docker.com/) is also required when adding or updating grammars. These components have their own dependencies - `icu4c`, and `cmake` and `pkg-config` respectively - which you may need to install before you can install Linguist. -For example, on macOS with [Homebrew](http://brew.sh/): `brew install cmake pkg-config icu4c` and on Ubuntu: `apt-get install cmake pkg-config libicu-dev`. +For example, on macOS with [Homebrew](http://brew.sh/): `brew install cmake pkg-config icu4c docker` and on Ubuntu: `apt-get install cmake pkg-config libicu-dev docker-ce`. ## Adding an extension to a language diff --git a/script/add-grammar b/script/add-grammar index 1b4f71d008..cdaa3066a5 100755 --- a/script/add-grammar +++ b/script/add-grammar @@ -84,6 +84,10 @@ unless $url exit 1; end +# Exit early if docker isn't installed or running. +log "Checking docker is installed and running" +command('docker', 'ps') + # Ensure the given URL is an HTTPS link parts = parse_url $url https = "https://#{parts[:host]}/#{parts[:user]}/#{parts[:repo]}" @@ -107,6 +111,7 @@ log "Confirming license" if repo_old command('script/licensed') else + repo_new = File.absolute_path(repo_new) command('script/licensed', '--module', repo_new) end