# commit = 1.5.3 (not tagged).
%global commit ad1e511f9d55b4ddf8afb3839635920d31f04a27

%global npmname color-string

Name:           nodejs-%{npmname}
Version:        1.5.3
Release:        1%{?dist}
Summary:        Parser and generator for CSS color strings

License:        MIT
URL:            https://www.npmjs.com/package/%{npmname}

#Source0:        https://github.com/Qix-/color-string/archive/%{version}/%{name}-%{version}.tar.gz
Source0:        https://registry.npmjs.org/%{npmname}/-/%{npmname}-%{version}.tgz

# Test. this release was not tagged on github, so we'll use the npm
# tarball, but since the test is just a single file... may as well grab it.
Source1:        https://raw.githubusercontent.com/Qix-/color-string/%{commit}/test/basic.js

BuildRequires:  nodejs-packaging

BuildRequires:  mocha
BuildRequires:  nodejs-color-name
BuildRequires:  nodejs-simple-swizzle

BuildArch:      noarch
ExclusiveArch: %{nodejs_arches} noarch

%description
Library for parsing and generating CSS color strings.

%prep
%autosetup -n package

# Manually install test file.
mkdir -p test/
cp %SOURCE1 test/

%nodejs_fixdep color-name

%build
# Nothing to build, this is a noarch package

%install
mkdir -p %{buildroot}%{nodejs_sitelib}/%{npmname}
cp -a index.js %{buildroot}%{nodejs_sitelib}/%{npmname}/
cp -a package.json %{buildroot}%{nodejs_sitelib}/%{npmname}/

%nodejs_symlink_deps

%check
%nodejs_symlink_deps --check
%{__nodejs} -e 'require("./")'

# Tests not present in npm archive, and the latest release was not
# tagged on github.
node test/basic.js

%files
%{nodejs_sitelib}/%{npmname}/
%license LICENSE
%doc README.md

%changelog
* Tue Apr 28 2020 Ben Rosser <rosser.bjr@gmail.com> - 1.5.3-1
- Initial package for Fedora.