48 Commits
Author SHA1 Message Date
TJ Holowaychuk 1159d4cac8 Release v1.2.0 2020-05-12 10:34:09 +01:00
92b4625797 Do not prune *.d.ts files (#66)
* Do not prune *.d.ts files

* Added --include and --exclude flags

Co-authored-by: dmattia <david@transcend.io>
2020-05-12 10:32:12 +01:00
TJ Holowaychuk 330b83e1fc remove goreleaser.yml 2020-02-15 10:52:10 +00:00
TJ Holowaychuk 888a2a83a0 Release v1.1.0 2020-02-10 15:43:48 +00:00
TJ Holowaychuk 8e33bde413 move cmd/node-prune to root 2020-02-10 15:43:28 +00:00
TJ Holowaychuk 230a021409 docs: add gobinaries.com install option 2020-02-10 15:40:57 +00:00
TJ Holowaychuk c73fc33576 add go.mod 2019-12-31 14:35:14 +00:00
Fabian LarrañagaandTJ Holowaychuk 16aeb704a5 Add missing comma on Default files declaration (#60) 2019-02-19 17:34:35 +00:00
Youngrok KimandTJ Holowaychuk 710bf6158b Added more files in the node ecosystem (#59) 2019-02-19 10:37:04 +00:00
Laith ShadeedandTJ Holowaychuk af886aad50 Add LICENSE (British version of the word) (#58)
Some npm modules use British English. Examples: dom-walk, min-document & xtend
2018-12-21 15:34:38 +00:00
Oguzhan InanandTJ Holowaychuk ea363c1e0d added .mkd, changelog, .eslintrc.yml ..... (#54)
added .mkd, changelog, .eslintrc.yml, LICENSE.BSD, LICENSE-MIT
2018-07-04 09:39:18 -07:00
TJ Holowaychuk e176926254 add install to /usr/local/bin example 2018-04-16 15:52:28 -07:00
Carlos Alexandro BeckerandTJ Holowaychuk 121f38b503 added curl | bash install instruction (#52)
this is extremely beta, see https://github.com/goreleaser/godownloader/issues/39
2018-04-16 15:50:57 -07:00
Lion RalfsandTJ Holowaychuk d58d0c5287 added stylelint variations (#46) 2017-12-08 11:27:56 -08:00
TJ Holowaychuk 1e61e90add gofmt 2017-12-01 07:14:52 -08:00
Thomas ReggiandTJ Holowaychuk b5cbf5ddd1 added license (#41) 2017-12-01 07:14:35 -08:00
Thomas ReggiandTJ Holowaychuk db2c298d2d added karma.conf.js (#42)
as seen in https://github.com/visionmedia/debug
2017-12-01 07:14:23 -08:00
Thomas ReggiandTJ Holowaychuk 43e6ab33d1 added .appveyor.yml (#43)
as seen in https://github.com/GoogleChrome/puppeteer
2017-12-01 07:13:41 -08:00
TJ HolowaychukandGitHub c38793fc48 Merge pull request #44 from reggi/patch-5
added tsconfig.json
2017-12-01 07:12:19 -08:00
TJ HolowaychukandGitHub b11afa5d72 Merge pull request #40 from reggi/patch-1
added .markdown
2017-12-01 07:12:12 -08:00
Thomas ReggiandGitHub 48ebbee903 added tsconfig.json
as seen https://github.com/GoogleChrome/puppeteer
2017-12-01 05:00:46 -05:00
Thomas ReggiandGitHub 0bc034b5b8 added .markdown 2017-12-01 04:50:29 -05:00
TJ HolowaychukandGitHub d62f3773b4 Merge pull request #37 from yarossia/patch-3
add more filenames to remove
2017-11-29 15:00:23 -08:00
Yaroslav PidmohylniyandGitHub 988e4c45cc add more filenames to remove 2017-11-30 00:58:13 +02:00
TJ HolowaychukandGitHub 980cf22f63 Merge pull request #34 from ceciliamvrie/patch-1
Update prune.go
2017-11-28 16:47:45 -08:00
Cecilia CisnerosandGitHub 3db7dfd67f Update prune.go 2017-11-28 18:40:37 -06:00
TJ HolowaychukandGitHub 9832cb44b0 Merge pull request #31 from techmexdev/patch-1
Update prune.go
2017-11-27 19:10:15 -08:00
Rodolfo RodriguezandGitHub 5f45fb2b96 Update prune.go 2017-11-27 20:36:39 -06:00
TJ HolowaychukandGitHub dda268cf31 Merge pull request #29 from axetroy/master
docs: Update Usage in package.json
2017-11-27 08:24:57 -08:00
AxetroyandGitHub ae6d8900ec docs: Update Usage in package.json 2017-11-27 15:12:43 +08:00
TJ Holowaychuk a431a05f9f fix missing comma 2017-11-26 18:31:43 -08:00
TJ HolowaychukandGitHub 922374d25e Merge pull request #27 from qWici/patch-1
Add jekyll config file to default files
2017-11-26 13:38:56 -08:00
Vania KucherandGitHub 513111e564 Add jekyll config file to default files 2017-11-26 22:54:30 +02:00
TJ Holowaychuk 713db670e6 docs 2017-11-25 15:36:55 -08:00
TJ Holowaychuk a98f1d559a add goreleaser.yml 2017-11-25 10:16:14 -08:00
TJ HolowaychukandGitHub 0f3fc40f99 Merge pull request #25 from fengmk2/patch-1
Remove appveyor.yml
2017-11-23 09:34:27 -08:00
fengmk2andGitHub f670f92454 Remove appveyor.yml 2017-11-24 00:33:52 +08:00
TJ HolowaychukandGitHub 3661fad3f0 Merge pull request #24 from axetroy/master
add .yarnclean and .github
2017-11-22 18:45:32 -08:00
axetroy 1ca4148802 add .yarnclean and .github 2017-11-23 10:29:42 +08:00
TJ HolowaychukandGitHub 9e508651aa Merge pull request #23 from jhegg/fix-syntax-error
Fix syntax errors
2017-11-22 14:16:56 -08:00
jhegg 2a00a8d8b7 Fix syntax errors
A previous commit missed some commas.
2017-11-22 13:42:42 -08:00
TJ Holowaychuk 0edbf73feb add license. Closes #21 2017-11-22 11:51:39 -08:00
TJ HolowaychukandGitHub 7cac001c09 Merge pull request #20 from Phanindra48/master
Add few more unnecessary files to the list
2017-11-22 11:03:42 -08:00
Phanindra fe422a88b7 remove infavor of *.md 2017-11-22 08:00:04 +05:30
Phanindra efa7590107 Add few more unnecessary files to the list 2017-11-22 05:50:36 +05:30
TJ Holowaychuk 0ab407615a add .gitignore 2017-11-21 10:58:43 -08:00
TJ HolowaychukandGitHub f130c7b785 Merge pull request #17 from appleboy/patch2
convert space to tabs.
2017-11-21 10:58:41 -08:00
Bo-Yi Wu bc9e4409af convert space to tabs.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2017-11-21 14:32:08 +08:00
8 changed files with 252 additions and 17 deletions
+1
View File
@@ -0,0 +1 @@
.envrc
+11
View File
@@ -0,0 +1,11 @@
v1.2.0 / 2020-05-12
===================
* add `--include` and `--exclude` flags
* remove goreleaser.yml
v1.1.0 / 2020-02-10
===================
* move `./cmd/node-prune/main.go` to root
+23
View File
@@ -0,0 +1,23 @@
(The MIT License)
Copyright (c) 2017 TJ Holowaychuk tj@tjholowaychuk.com
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+18 -2
View File
@@ -2,12 +2,20 @@
## What?
node-prune is a small tool to prune unnecessary files from ./node_modules, such as markdown, typescript source files, and so on.
node-prune is a small tool to prune unnecessary files from ./node_modules, such as markdown, typescript source files, and so on. Primarily built for [Up](https://github.com/apex/up) which lets you deploy serverless web applications in seconds.
## Installation
From [gobinaries.com](https://gobinaries.com):
```sh
$ curl -sf https://gobinaries.com/tj/node-prune | sh
```
$ go get github.com/tj/node-prune/cmd/node-prune
From source:
```
$ go get github.com/tj/node-prune
```
## Usage
@@ -34,6 +42,14 @@ size removed 13 MB
duration 200ms
```
Or add to the ``package.json`` scripts field
```
"scripts": {
"postinstall": "node-prune"
}
```
## Why?
![huge](https://pbs.twimg.com/media/DEIV_1XWsAAlY29.jpg)
+8
View File
@@ -0,0 +1,8 @@
module github.com/tj/node-prune
go 1.13
require (
github.com/apex/log v1.1.1
github.com/dustin/go-humanize v1.0.0
)
+61
View File
@@ -0,0 +1,61 @@
github.com/apex/log v1.1.1 h1:BwhRZ0qbjYtTob0I+2M+smavV0kOC8XgcnGZcyL9liA=
github.com/apex/log v1.1.1/go.mod h1:Ls949n1HFtXfbDcjiTTFQqkVUrte0puoIBfO3SVgwOA=
github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE=
github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys=
github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7/go.mod h1:2iMrUgbbvHEiQClaW2NsSzMyGHqN+rDFqY705q49KG0=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.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/rogpeppe/fastuuid v1.1.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
github.com/smartystreets/gunit v1.0.0/go.mod h1:qwPWnhz6pn0NnRBP++URONOVyNkPyr4SauJk4cUOwJs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/tj/assert v0.0.0-20171129193455-018094318fb0/go.mod h1:mZ9/Rh9oLWpLLDRpvE+3b7gP/C2YyLFYxNmcLnPTMe0=
github.com/tj/go-elastic v0.0.0-20171221160941-36157cbbebc2/go.mod h1:WjeM0Oo1eNAjXGDx2yma7uG2XoyRZTq1uv3M/o7imD0=
github.com/tj/go-kinesis v0.0.0-20171128231115-08b17f58cb1b/go.mod h1:/yhzCV0xPfx6jb1bBgRFjl5lytqVqZXEaeqWP8lTEao=
github.com/tj/go-spin v1.1.0/go.mod h1:Mg1mzmePZm4dva8Qz60H2lHwmJ2loum4VIrLgVnKwh4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+101 -14
View File
@@ -15,24 +15,73 @@ import (
//
// Copied from yarn (mostly).
var DefaultFiles = []string{
"Jenkinsfile",
"Makefile",
"Gulpfile.js",
"Gruntfile.js",
"gulpfile.js",
".DS_Store",
".tern-project",
".gitattributes",
".editorconfig",
".eslintrc",
"eslint",
".eslintrc.js",
".eslintrc.json",
".eslintrc.yml",
".eslintignore",
".stylelintrc",
"stylelint.config.js",
".stylelintrc.json",
".stylelintrc.yaml",
".stylelintrc.yml",
".stylelintrc.js",
".htmllintrc",
"htmllint.js",
".lint",
".npmrc",
".npmignore",
".jshintrc",
".flowconfig",
".documentup.json",
".yarn-metadata.json",
".travis.yml",
"appveyor.yml",
".gitlab-ci.yml",
"circle.yml",
".coveralls.yml",
"CHANGES",
"changelog",
"LICENSE.txt",
"LICENSE",
"LICENSE-MIT",
"LICENSE.BSD",
"license",
"LICENCE.txt",
"LICENCE",
"LICENCE-MIT",
"LICENCE.BSD",
"licence",
"AUTHORS",
"CONTRIBUTORS",
".yarn-integrity",
".yarnclean",
"_config.yml",
".babelrc",
".yo-rc.json",
"jest.config.js",
"karma.conf.js",
"wallaby.js",
"wallaby.conf.js",
".prettierrc",
".prettierrc.yml",
".prettierrc.toml",
".prettierrc.js",
".prettierrc.json",
"prettier.config.js",
".appveyor.yml",
"tsconfig.json",
"tslint.json",
}
// DefaultDirectories pruned.
@@ -54,16 +103,20 @@ var DefaultDirectories = []string{
"examples",
"coverage",
".nyc_output",
".circleci",
".github",
}
// DefaultExtensions pruned.
var DefaultExtensions = []string{
".markdown",
".md",
".mkd",
".ts",
".jst",
".coffee",
".tgz",
".swp",
".swp",
}
// Stats for a prune.
@@ -75,13 +128,15 @@ type Stats struct {
// Pruner is a module pruner.
type Pruner struct {
dir string
log log.Interface
dirs map[string]struct{}
exts map[string]struct{}
files map[string]struct{}
ch chan func()
wg sync.WaitGroup
dir string
log log.Interface
dirs map[string]struct{}
exts map[string]struct{}
excepts []string
globs []string
files map[string]struct{}
ch chan func()
wg sync.WaitGroup
}
// Option function.
@@ -90,12 +145,14 @@ type Option func(*Pruner)
// New with the given options.
func New(options ...Option) *Pruner {
v := &Pruner{
dir: "node_modules",
log: log.Log,
exts: toMap(DefaultExtensions),
dirs: toMap(DefaultDirectories),
files: toMap(DefaultFiles),
ch: make(chan func()),
dir: "node_modules",
log: log.Log,
exts: toMap(DefaultExtensions),
excepts: []string{},
globs: []string{},
dirs: toMap(DefaultDirectories),
files: toMap(DefaultFiles),
ch: make(chan func()),
}
for _, o := range options {
@@ -112,6 +169,20 @@ func WithDir(s string) Option {
}
}
// WithGlobs option.
func WithGlobs(s []string) Option {
return func(v *Pruner) {
v.globs = s
}
}
// WithExceptions option.
func WithExceptions(s []string) Option {
return func(v *Pruner) {
v.excepts = s
}
}
// WithExtensions option.
func WithExtensions(s []string) Option {
return func(v *Pruner) {
@@ -195,6 +266,22 @@ func (p *Pruner) Prune() (*Stats, error) {
// prune returns true if the file or dir should be pruned.
func (p *Pruner) prune(path string, info os.FileInfo) bool {
// exceptions
for _, glob := range p.excepts {
matched, _ := filepath.Match(glob, info.Name())
if matched {
return false
}
}
// globs
for _, glob := range p.globs {
matched, _ := filepath.Match(glob, info.Name())
if matched {
return true
}
}
// directories
if info.IsDir() {
_, ok := p.dirs[info.Name()]
+29 -1
View File
@@ -3,13 +3,14 @@ package main
import (
"flag"
"fmt"
"strings"
"time"
"github.com/apex/log"
"github.com/apex/log/handlers/cli"
"github.com/dustin/go-humanize"
"github.com/tj/node-prune"
"github.com/tj/node-prune/internal/prune"
)
func init() {
@@ -17,8 +18,27 @@ func init() {
log.SetLevel(log.WarnLevel)
}
type arrayFlags []string
func (i *arrayFlags) String() string {
return strings.Join(*i, ", ")
}
func (i *arrayFlags) Set(value string) error {
*i = append(*i, value)
return nil
}
// Globs of files that should not be pruned
var exclusionGlobs arrayFlags
// Globs of files that should always be pruned in addition to the defaults
var inclusionGlobs arrayFlags
func main() {
debug := flag.Bool("verbose", false, "Verbose log output.")
flag.Var(&exclusionGlobs, "exclude", "Glob of files that should not be pruned. Can be specified multiple times.")
flag.Var(&inclusionGlobs, "include", "Globs of files that should always be pruned in addition to the defaults. Can be specified multiple times.")
flag.Parse()
dir := flag.Arg(0)
@@ -34,6 +54,14 @@ func main() {
options = append(options, prune.WithDir(dir))
}
if len(exclusionGlobs) > 0 {
options = append(options, prune.WithExceptions(exclusionGlobs))
}
if len(inclusionGlobs) > 0 {
options = append(options, prune.WithGlobs(inclusionGlobs))
}
p := prune.New(options...)
stats, err := p.Prune()