Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colordiff #4

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions History.md
@@ -1,3 +1,8 @@
1.2.0 / 2019-03-22
==================

* differentiating between Linux and MacOS
* download and install colordiff

1.1.0 / 2014-02-13
==================
Expand Down
13 changes: 13 additions & 0 deletions Makefile
@@ -1,5 +1,6 @@

PREFIX ?= /usr/local
SO := $(shell uname)

install: npm-diff
cp $< $(PREFIX)/bin/$<
Expand All @@ -9,3 +10,15 @@ uninstall:

.PHONY: install uninstall

colordiff_linux:
apt-get install colordiff --allow-unauthenticated -y

colordiff_mac:
brew install colordiff

colordiff:
ifeq ($(SO), Linux)
make colordiff_linux
else
make colordiff_mac
endif
10 changes: 5 additions & 5 deletions README.md
@@ -1,5 +1,5 @@

# npm-diff(1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 doesn't refer to the version, but that it's a user level tool, which is a convention known from unix systems.

# npm-diff(2)

Diff two versions of a node module.

Expand Down Expand Up @@ -34,11 +34,11 @@ $ npm-diff intersect 0.0.0 0.1.0 | less
$ npm-diff intersect 0.0.0 0.1.0 | colordiff | less -R
```

## Sponsors
DanielVenturini marked this conversation as resolved.
Show resolved Hide resolved
If you don't have [colordiff](http://www.colordiff.org), and want to use it (on the Linux, use sudo; in the Mac, don't use):

This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!

Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
```bash
$ make colordiff
```

## License

Expand Down
28 changes: 24 additions & 4 deletions npm-diff
@@ -1,11 +1,12 @@
#!/usr/bin/env bash

#
# npm-diff(1)
# npm-diff(2)
#
# MIT licensed
# (c) 2014 Segment.io <friends@segment.io>
# (c) 2018 Julian Gruber <mail@juliangruber.com>
# (c) 2019 Daniel Venturini <danielventurini@alunos.utfpr.edu.br>
#

set -e
Expand All @@ -27,8 +28,27 @@ work=/tmp/$RANDOM
mkdir $work
cd $work

# get the url when was passed a range version
#get_url() {
# version=$1
# urls=$(npm show $module@$version dist.tarball 2>/dev/null)
#}
# download

get_url() {
version=$1
url=""
urls=$(npm show $module@$version dist.tarball >$work/$version/urls)
input="$work/$version/urls"

while IFS= read -r var
do
url=$var
done < "$input"

retval=$url
}

download(){
version=$1
mkdir $version
Expand All @@ -39,7 +59,8 @@ download(){
user="--user $(cat ~/.npmrc | grep _auth | cut -d' ' -f3 | base64 --decode)"
fi

url=$(npm show $module@$version dist.tarball 2>/dev/null)
get_url $version
url=$retval
curl --fail --silent --insecure $user $url | tar -xz --strip 1
if [[ ${PIPESTATUS[0]} != 0 ]]; then
echo "Unknown version: $module@$1"
Expand All @@ -64,5 +85,4 @@ diff \

# cleanup

rm -Rf $work

rm -Rf $work