From 54fd3bc12f037b727a8ca9537e0008e5331b4645 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Fri, 18 Jun 2021 16:55:49 +1000 Subject: [PATCH] Clean up imports and make cmd/chroma its own module. --- .goreleaser.yml | 3 ++- cmd/chroma/go.mod | 12 ++++++++++++ cmd/chroma/go.sum | 29 +++++++++++++++++++++++++++++ coalesce_test.go | 2 +- colour_test.go | 2 +- delegate_test.go | 2 +- formatters/html/html_test.go | 2 +- formatters/tty_indexed_test.go | 2 +- go.mod | 12 ++---------- go.sum | 22 ---------------------- lexer_test.go | 2 +- lexers/c/cpp_test.go | 2 +- lexers/g/go_test.go | 2 +- lexers/lexer_benchmark_test.go | 2 +- lexers/lexers_test.go | 2 +- mutators_test.go | 2 +- regexp_test.go | 2 +- remap_test.go | 2 +- style_test.go | 2 +- 19 files changed, 59 insertions(+), 47 deletions(-) create mode 100644 cmd/chroma/go.mod create mode 100644 cmd/chroma/go.sum diff --git a/.goreleaser.yml b/.goreleaser.yml index f8abfdd..b2ccbc7 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -18,7 +18,8 @@ builds: - "386" goarm: - "6" - main: ./cmd/chroma/main.go + dir: ./cmd/chroma + main: . ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} binary: chroma archives: diff --git a/cmd/chroma/go.mod b/cmd/chroma/go.mod new file mode 100644 index 0000000..7fa2257 --- /dev/null +++ b/cmd/chroma/go.mod @@ -0,0 +1,12 @@ +module github.com/alecthomas/chroma/cmd/chroma + +go 1.16 + +replace github.com/alecthomas/chroma => ../../ + +require ( + github.com/alecthomas/chroma v0.0.0-00010101000000-000000000000 + github.com/alecthomas/kong v0.2.17 + github.com/mattn/go-colorable v0.1.8 + github.com/mattn/go-isatty v0.0.13 +) diff --git a/cmd/chroma/go.sum b/cmd/chroma/go.sum new file mode 100644 index 0000000..53b3a5a --- /dev/null +++ b/cmd/chroma/go.sum @@ -0,0 +1,29 @@ +github.com/alecthomas/kong v0.2.17 h1:URDISCI96MIgcIlQyoCAlhOmrSw6pZScBNkctg8r0W0= +github.com/alecthomas/kong v0.2.17/go.mod h1:ka3VZ8GZNPXv9Ov+j4YNLkI8mTuhXyr/0ktSlqIydQQ= +github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= +github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= +github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA= +github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/coalesce_test.go b/coalesce_test.go index 56814f5..ffae48e 100644 --- a/coalesce_test.go +++ b/coalesce_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" ) func TestCoalesce(t *testing.T) { diff --git a/colour_test.go b/colour_test.go index adc8544..9281399 100644 --- a/colour_test.go +++ b/colour_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" ) func TestColourRGB(t *testing.T) { diff --git a/delegate_test.go b/delegate_test.go index a93902d..d8a4994 100644 --- a/delegate_test.go +++ b/delegate_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" ) func makeDelegationTestLexers() (lang Lexer, root Lexer) { diff --git a/formatters/html/html_test.go b/formatters/html/html_test.go index b261ade..70c08e6 100644 --- a/formatters/html/html_test.go +++ b/formatters/html/html_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" "github.com/alecthomas/chroma" "github.com/alecthomas/chroma/lexers" diff --git a/formatters/tty_indexed_test.go b/formatters/tty_indexed_test.go index fdc0db1..1216a49 100644 --- a/formatters/tty_indexed_test.go +++ b/formatters/tty_indexed_test.go @@ -3,8 +3,8 @@ package formatters import ( "testing" - "github.com/alecthomas/assert" "github.com/alecthomas/chroma" + "github.com/stretchr/testify/assert" ) func TestClosestColour(t *testing.T) { diff --git a/go.mod b/go.mod index 3baf1cb..de08df4 100644 --- a/go.mod +++ b/go.mod @@ -3,16 +3,8 @@ module github.com/alecthomas/chroma go 1.13 require ( - github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 - github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect - github.com/alecthomas/kong v0.2.4 - github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 // indirect github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 + github.com/davecgh/go-spew v1.1.1 // indirect github.com/dlclark/regexp2 v1.4.0 - github.com/mattn/go-colorable v0.1.6 - github.com/mattn/go-isatty v0.0.12 - github.com/pkg/errors v0.9.1 // indirect - github.com/sergi/go-diff v1.0.0 // indirect - github.com/stretchr/testify v1.3.0 // indirect - golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 // indirect + github.com/stretchr/testify v1.3.0 ) diff --git a/go.sum b/go.sum index 12000b7..1e0c6c8 100644 --- a/go.sum +++ b/go.sum @@ -1,11 +1,3 @@ -github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U= -github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI= -github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo= -github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= -github.com/alecthomas/kong v0.2.4 h1:Y0ZBCHAvHhTHw7FFJ2FzCAAG4pkbTgA45nc7BpMhDNk= -github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= -github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY= -github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -13,22 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200413165638-669c56c373c4 h1:opSr2sbRXk5X5/givKrrKj9HXxFpW2sdCiP8MJSKLQY= -golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/lexer_test.go b/lexer_test.go index c47566f..412ae9c 100644 --- a/lexer_test.go +++ b/lexer_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" ) func TestTokenTypeClassifiers(t *testing.T) { diff --git a/lexers/c/cpp_test.go b/lexers/c/cpp_test.go index 8f1b0b3..ef9e41d 100644 --- a/lexers/c/cpp_test.go +++ b/lexers/c/cpp_test.go @@ -3,7 +3,7 @@ package c_test import ( "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" "github.com/alecthomas/chroma" "github.com/alecthomas/chroma/lexers/c" diff --git a/lexers/g/go_test.go b/lexers/g/go_test.go index 2b949b2..050ff88 100644 --- a/lexers/g/go_test.go +++ b/lexers/g/go_test.go @@ -3,8 +3,8 @@ package g import ( "testing" - "github.com/alecthomas/assert" "github.com/alecthomas/chroma" + "github.com/stretchr/testify/assert" ) func TestGoHTMLTemplateIssue126(t *testing.T) { diff --git a/lexers/lexer_benchmark_test.go b/lexers/lexer_benchmark_test.go index c0d805b..326e376 100644 --- a/lexers/lexer_benchmark_test.go +++ b/lexers/lexer_benchmark_test.go @@ -3,9 +3,9 @@ package lexers_test import ( "testing" - "github.com/alecthomas/assert" "github.com/alecthomas/chroma" "github.com/alecthomas/chroma/lexers/g" + "github.com/stretchr/testify/assert" ) const lexerBenchSource = `// Copyright 2011 The Go Authors. All rights reserved. diff --git a/lexers/lexers_test.go b/lexers/lexers_test.go index 0c5d840..306ed67 100644 --- a/lexers/lexers_test.go +++ b/lexers/lexers_test.go @@ -9,13 +9,13 @@ import ( "strings" "testing" - "github.com/alecthomas/assert" "github.com/alecthomas/chroma" "github.com/alecthomas/chroma/formatters" "github.com/alecthomas/chroma/lexers" "github.com/alecthomas/chroma/lexers/a" "github.com/alecthomas/chroma/lexers/x" "github.com/alecthomas/chroma/styles" + "github.com/stretchr/testify/assert" ) func TestCompileAllRegexes(t *testing.T) { diff --git a/mutators_test.go b/mutators_test.go index 99ebfdd..225174f 100644 --- a/mutators_test.go +++ b/mutators_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" ) func TestInclude(t *testing.T) { diff --git a/regexp_test.go b/regexp_test.go index 5b6007d..96b54dd 100644 --- a/regexp_test.go +++ b/regexp_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" ) func TestNewlineAtEndOfFile(t *testing.T) { diff --git a/remap_test.go b/remap_test.go index d6d986d..460cfe0 100644 --- a/remap_test.go +++ b/remap_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" ) func TestRemappingLexer(t *testing.T) { diff --git a/style_test.go b/style_test.go index 0a2292b..dcd36c0 100644 --- a/style_test.go +++ b/style_test.go @@ -3,7 +3,7 @@ package chroma import ( "testing" - "github.com/alecthomas/assert" + "github.com/stretchr/testify/assert" ) func TestStyleInherit(t *testing.T) {