%{?nodejs_find_provides_and_requires}

# NOTE TO SELF: Do not update on Fedora <= 20.

%global enable_tests 0

%if 0%{?fedora}
%global installdir  %{_jsdir}/underscore
%else
%global installdir  %{_datadir}/javascript/underscore
%endif

Name:       nodejs-underscore
Version:    1.9.1
Release:    5%{?dist}
Summary:    JavaScript's functional programming helper library
License:    MIT
URL:        http://underscorejs.org/
Source0:    http://registry.npmjs.org/underscore/-/underscore-%{version}.tgz
# The test files are not included in the npm tarball.
# Source1 is generated by running Source10, which pulls from the upstream
# version control repository.
Source1:    tests-%{version}.tar.bz2
Source10:   dl-tests.sh

BuildArch:  noarch
%if 0%{?fedora} >= 19
ExclusiveArch: %{nodejs_arches} noarch
%else
ExclusiveArch: %{ix86} x86_64 %{arm} noarch
%endif

%if 0%{?fedora}
BuildRequires:  web-assets-devel
%endif

BuildRequires:  nodejs-packaging
BuildRequires:  uglify-js

%if 0%{?enable_tests}
BuildRequires:  npm(phantomjs)
%endif

%description
Underscore.js is a utility-belt library for JavaScript that provides support
for the usual functional suspects (each, map, reduce, filter...) without
extending any core JavaScript objects.

%package -n js-underscore
Summary:    JavaScript's functional programming helper library
%if 0%{?fedora}
Requires:   web-assets-filesystem
%endif

%description -n js-underscore
Underscore.js is a utility-belt library for JavaScript that provides support
for the usual functional suspects (each, map, reduce, filter...) without
extending any core JavaScript objects.

%prep
%setup -q -n package
%setup -T -D -a 1 -q -n package
rm -f underscore-min.*


%build
/usr/bin/uglifyjs underscore.js -m --source-map underscore-min.map \
    -o underscore-min.js


%install
mkdir -p %{buildroot}%{nodejs_sitelib}/underscore
cp -pr package.json underscore.js underscore-min.js underscore-min.map \
    %{buildroot}%{nodejs_sitelib}/underscore

# Install browser version
mkdir -p %{buildroot}%{installdir}
cp -pr underscore.js underscore-min.js underscore-min.map \
    %{buildroot}%{installdir}

# No dependencies.
# %%nodejs_symlink_deps


%if 0%{?enable_tests}
%check
%nodejs_symlink_deps --check
%{nodejs_sitelib}/phantomjs/bin/phantomjs \
    test/vendor/runner.js test/index.html?noglobals=true
%endif


%files
%doc LICENSE README.md
%{nodejs_sitelib}/underscore

%files -n js-underscore
%doc LICENSE README.md
%{installdir}


%changelog
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.1-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.9.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Mon Jun 04 2018 Dan Callaghan <dcallagh@redhat.com> - 1.9.1-1
- upstream release 1.9.1

* Mon Apr 30 2018 Dan Callaghan <dcallagh@redhat.com> - 1.9.0-1
- upstream release 1.9.0

* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.8.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.8.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.8.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.8.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Sep 03 2015 Dan Callaghan <dcallagh@redhat.com> - 1.8.3-1
- update to upstream release 1.8.3

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Thu May 08 2014 Jamie Nguyen <jamielinux@fedoraproject.org> - 1.6.0-3
- depend explicitly on latest version of uglifyjs

* Sat Apr 26 2014 Jamie Nguyen <jamielinux@fedoraproject.org> - 1.6.0-2
- add jsdir logic for EL6

* Fri Apr 18 2014 Jamie Nguyen <jamielinux@fedoraproject.org> - 1.6.0-1
- update to upstream release 1.6.0

* Sun Jan 19 2014 T.C. Hollingsworth <tchollingsworth@gmail.com> - 1.5.1-2
- ship a browser version
- add missing BuildRequires on uglify-js
- remove no longer present documentation files

* Sun Aug 18 2013 Jamie Nguyen <jamielinux@fedoraproject.org> - 1.5.1-1
- update to upstream release 1.5.1
- remove pre-compiled JS and use uglifyjs to compile

* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.4.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Wed Jun 19 2013 T.C. Hollingsworth <tchollingsworth@gmail.com> - 1.4.4-2
- rebuild for missing npm(underscore) provides on EL6

* Wed Feb 13 2013 Jamie Nguyen <jamielinux@fedoraproject.org> - 1.4.4-1
- initial package
