Skip to content

Instantly share code, notes, and snippets.

@PhantomRay
Forked from gpittarelli/node_prune.sh
Last active March 10, 2021 13:17
Show Gist options
  • Save PhantomRay/ba98b8d082876d9cfb6c9b683caae75f to your computer and use it in GitHub Desktop.
Save PhantomRay/ba98b8d082876d9cfb6c9b683caae75f to your computer and use it in GitHub Desktop.

Revisions

  1. PhantomRay revised this gist Mar 10, 2021. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,6 @@ find . -type d -name node_modules -prune -exec find {} -type f \( \
    -name .yarn-integrity -or \
    -name "*.md" -or \
    -name "*.sln" -or \
    -name "*.obj" -or \
    -name "*.gypi" -or \
    -name "*.vcxproj" -or \
    -name "*.vcxproj.filters" -or \
  2. PhantomRay revised this gist Mar 4, 2021. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -57,6 +57,8 @@ find . -type d -name node_modules -prune -exec find {} -type f \( \
    -name "*.map" -or \
    -name "*.jst" -or \
    -name "*.coffee" \
    -name "*.c" \
    -name "*.h" \
    \) -print0 \; | xargs -0 rm -rf

    # Common unneeded directories
    @@ -67,9 +69,6 @@ find . -type d -name node_modules -prune -exec find {} -type d \( \
    -name powered-test -or \
    -name docs -or \
    -name doc -or \
    -name website -or \
    -name images -or \
    -name assets -or \
    -name example -or \
    -name examples -or \
    -name coverage -or \
  3. PhantomRay revised this gist Jun 11, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -54,7 +54,7 @@ find . -type d -name node_modules -prune -exec find {} -type f \( \
    -name "*.vcxproj" -or \
    -name "*.vcxproj.filters" -or \
    -name "*.ts" -or \
    \( -name '*.ts' -and \! -name '*.d.ts' \) -or \
    -name "*.map" -or \
    -name "*.jst" -or \
    -name "*.coffee" \
    \) -print0 \; | xargs -0 rm -rf
  4. PhantomRay revised this gist Jun 11, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -53,6 +53,7 @@ find . -type d -name node_modules -prune -exec find {} -type f \( \
    -name "*.gypi" -or \
    -name "*.vcxproj" -or \
    -name "*.vcxproj.filters" -or \
    -name "*.ts" -or \
    \( -name '*.ts' -and \! -name '*.d.ts' \) -or \
    -name "*.jst" -or \
    -name "*.coffee" \
  5. @gpittarelli gpittarelli revised this gist Nov 19, 2017. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -37,10 +37,15 @@ find . -type d -name node_modules -prune -exec find {} -type f \( \
    -name .documentup.json -or \
    -name .yarn-metadata.json -or \
    -name .travis.yml -or \
    -name thumbs.db -or \
    -name .ds_store -or \
    -name desktop.ini -or \
    -name npm-debug.log -or \
    -name .npmrc -or \
    -iname LICENSE.txt -or \
    -iname LICENSE -or \
    -name AUTHORS -or \
    -name CONTRIBUTORS -or \
    -iname AUTHORS -or \
    -iname CONTRIBUTORS -or \
    -name .yarn-integrity -or \
    -name "*.md" -or \
    -name "*.sln" -or \
  6. @gpittarelli gpittarelli revised this gist Nov 19, 2017. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,11 @@
    # - fixed "*.ts" being overzealous and killing .d.ts files
    # - added some more file types from https://github.com/npm/npm/issues/5264#issuecomment-259800486
    #
    # See also:
    # - https://github.com/timoxley/cruft
    # - https://yarnpkg.com/en/docs/cli/autoclean
    # - https://github.com/ModClean/modclean
    #
    # Prunes common files that are unnecessarily published in npm packages
    # when people don't configure `.npmignore` or package.json's `files`

  7. @gpittarelli gpittarelli revised this gist Nov 19, 2017. 1 changed file with 23 additions and 3 deletions.
    26 changes: 23 additions & 3 deletions node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    #!/usr/bin/env bash
    # Port of https://github.com/tj/node-prune to bash
    # Also,
    # - fixed "*.ts" being overzealous and killing .d.ts files
    # - added some more file types from https://github.com/npm/npm/issues/5264#issuecomment-259800486
    #
    # Prunes common files that are unnecessarily published in npm packages
    # when people don't configure `.npmignore` or package.json's `files`
    @@ -8,7 +11,16 @@ echo "Before: "$(du -hs .)

    # Common unneeded files
    find . -type d -name node_modules -prune -exec find {} -type f \( \
    -name Makefile -or \
    -iname Makefile -or \
    -iname README -or \
    -iname README.md -or \
    -iname CHANGELOG -or \
    -iname CHANGELOG.md -or \
    -name .editorconfig -or \
    -name .gitmodules -or \
    -name .gitattributes -or \
    -name robot.html -or \
    -name .lint -or \
    -name Gulpfile.js -or \
    -name Gruntfile.js -or \
    -name .tern-project -or \
    @@ -20,12 +32,17 @@ find . -type d -name node_modules -prune -exec find {} -type f \( \
    -name .documentup.json -or \
    -name .yarn-metadata.json -or \
    -name .travis.yml -or \
    -name LICENSE.txt -or \
    -name LICENSE -or \
    -iname LICENSE.txt -or \
    -iname LICENSE -or \
    -name AUTHORS -or \
    -name CONTRIBUTORS -or \
    -name .yarn-integrity -or \
    -name "*.md" -or \
    -name "*.sln" -or \
    -name "*.obj" -or \
    -name "*.gypi" -or \
    -name "*.vcxproj" -or \
    -name "*.vcxproj.filters" -or \
    \( -name '*.ts' -and \! -name '*.d.ts' \) -or \
    -name "*.jst" -or \
    -name "*.coffee" \
    @@ -45,6 +62,9 @@ find . -type d -name node_modules -prune -exec find {} -type d \( \
    -name example -or \
    -name examples -or \
    -name coverage -or \
    -name node-gyp -or \
    -name node-pre-gyp -or \
    -name gyp -or \
    -name .nyc_output \
    \) -print0 \; | xargs -0 rm -rf

  8. @gpittarelli gpittarelli revised this gist Nov 19, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    #!/usr/bin/env bash
    # Port of https://github.com/tj/node-prune to bash
    #
    # Prunes common files that are unnecessarily published in npm packages
  9. @gpittarelli gpittarelli revised this gist Nov 19, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ find . -type d -name node_modules -prune -exec find {} -type f \( \
    -name CONTRIBUTORS -or \
    -name .yarn-integrity -or \
    -name "*.md" -or \
    -name "*.ts" -or \
    \( -name '*.ts' -and \! -name '*.d.ts' \) -or \
    -name "*.jst" -or \
    -name "*.coffee" \
    \) -print0 \; | xargs -0 rm -rf
  10. @gpittarelli gpittarelli revised this gist Nov 19, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Port of https://news.ycombinator.com/item?id=15731936 to bash
    # Port of https://github.com/tj/node-prune to bash
    #
    # Prunes common files that are unnecessarily published in npm packages
    # when people don't configure `.npmignore` or package.json's `files`
  11. @gpittarelli gpittarelli revised this gist Nov 19, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Port of https://news.ycombinator.com/item?id=15731936 to bash
    #
    # Prunes common files that are unnecessarily published in npm packages
    # when people don't configure `.npmignore` of `files`
    # when people don't configure `.npmignore` or package.json's `files`

    echo "Before: "$(du -hs .)

  12. @gpittarelli gpittarelli revised this gist Nov 19, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    echo "Before: "$(du -hs .)

    # Common unneeded files
    find . -type d -name node_modules -prune -exec find {} -delete -type f \( \
    find . -type d -name node_modules -prune -exec find {} -type f \( \
    -name Makefile -or \
    -name Gulpfile.js -or \
    -name Gruntfile.js -or \
    @@ -28,10 +28,10 @@ find . -type d -name node_modules -prune -exec find {} -delete -type f \( \
    -name "*.ts" -or \
    -name "*.jst" -or \
    -name "*.coffee" \
    \) \;
    \) -print0 \; | xargs -0 rm -rf

    # Common unneeded directories
    find . -type d -name node_modules -prune -exec find {} -delete -type d \( \
    find . -type d -name node_modules -prune -exec find {} -type d \( \
    -name __tests__ -or \
    -name test -or \
    -name tests -or \
    @@ -45,7 +45,7 @@ find . -type d -name node_modules -prune -exec find {} -delete -type d \( \
    -name examples -or \
    -name coverage -or \
    -name .nyc_output \
    \) \;
    \) -print0 \; | xargs -0 rm -rf


    echo "After: "$(du -hs .)
  13. @gpittarelli gpittarelli revised this gist Nov 19, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ find . -type d -name node_modules -prune -exec find {} -delete -type f \( \
    \) \;

    # Common unneeded directories
    find . -type d -name node_modules -prune -exec find {} -type d \( \
    find . -type d -name node_modules -prune -exec find {} -delete -type d \( \
    -name __tests__ -or \
    -name test -or \
    -name tests -or \
  14. @gpittarelli gpittarelli created this gist Nov 19, 2017.
    51 changes: 51 additions & 0 deletions node_prune.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    # Port of https://news.ycombinator.com/item?id=15731936 to bash
    #
    # Prunes common files that are unnecessarily published in npm packages
    # when people don't configure `.npmignore` of `files`

    echo "Before: "$(du -hs .)

    # Common unneeded files
    find . -type d -name node_modules -prune -exec find {} -delete -type f \( \
    -name Makefile -or \
    -name Gulpfile.js -or \
    -name Gruntfile.js -or \
    -name .tern-project -or \
    -name .gitattributes -or \
    -name .editorconfig -or \
    -name .eslintrc -or \
    -name .jshintrc -or \
    -name .flowconfig -or \
    -name .documentup.json -or \
    -name .yarn-metadata.json -or \
    -name .travis.yml -or \
    -name LICENSE.txt -or \
    -name LICENSE -or \
    -name AUTHORS -or \
    -name CONTRIBUTORS -or \
    -name .yarn-integrity -or \
    -name "*.md" -or \
    -name "*.ts" -or \
    -name "*.jst" -or \
    -name "*.coffee" \
    \) \;

    # Common unneeded directories
    find . -type d -name node_modules -prune -exec find {} -type d \( \
    -name __tests__ -or \
    -name test -or \
    -name tests -or \
    -name powered-test -or \
    -name docs -or \
    -name doc -or \
    -name website -or \
    -name images -or \
    -name assets -or \
    -name example -or \
    -name examples -or \
    -name coverage -or \
    -name .nyc_output \
    \) \;


    echo "After: "$(du -hs .)