%{?nodejs_find_provides_and_requires}

%global enable_tests 0

Name:       nodejs-shelljs
Version:    0.7.3
Release:    3%{?dist}
Summary:    Portable Unix shell commands for Node.js
# The bulk of the project is licensed under BSD license.
# src/cp.js and src/rm.js contain MIT licensed code.
# https://fedorahosted.org/fpc/ticket/413
License:    BSD and MIT
Group:      System Environment/Libraries
URL:        http://github.com/arturadib/shelljs
Source0:    http://registry.npmjs.org/shelljs/-/shelljs-%{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

# The "shjs.js" test file is failing in mock
# when run from scripts/run-tests.js
#
# So, to make a long story short, we'll patch it out of the
# run-tests.js script
Patch0:     nodejs-shelljs_fix-tests.patch

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

BuildRequires:  nodejs-packaging
%if 0%{?enable_tests}
BuildRequires:  coffee-script
BuildRequires:  npm(glob)
%endif

%description
%{summary}.


%prep
%setup -q -n package
%setup -q -T -D -a 1 -n package
%patch0 -p1

sed -i '1s/env //' bin/shjs

%nodejs_fixdep glob

%build
#nothing to do


%install
mkdir -p %{buildroot}%{nodejs_sitelib}/shelljs
cp -pr package.json global.js make.js shell.js src/ \
    %{buildroot}%{nodejs_sitelib}/shelljs

mkdir -p %{buildroot}%{nodejs_sitelib}/shelljs/bin
install -p -m0755 bin/shjs \
    %{buildroot}%{nodejs_sitelib}/shelljs/bin
mkdir -p %{buildroot}%{_bindir}
ln -sf %{nodejs_sitelib}/shelljs/bin/shjs \
    %{buildroot}%{_bindir}/shjs

%nodejs_symlink_deps


%check
%nodejs_symlink_deps --check
%{__nodejs} -e 'require("./")'
%if 0%{?enable_tests}
%__nodejs scripts/run-tests
%else
%{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m"
%endif


%files
%{!?_licensedir:%global license %doc}
%license LICENSE
%doc README.md MAINTAINERS
%{nodejs_sitelib}/shelljs
%{_bindir}/shjs


%changelog
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

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

* Sat May 06 2017 Jared Smith <jsmith@fedoraproject.org> - 0.7.3-1
- Update to upstream 0.7.3 release

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

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

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

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

* Thu May 15 2014 Jamie Nguyen <jamielinux@fedoraproject.org> - 0.3.0-1
- update to upstream release 0.3.0
- fix License tag
- patch out jshint tests
- include copy of the MIT license

* Sat Mar 29 2014 Jamie Nguyen <jamielinux@fedoraproject.org> - 0.2.6-1
- initial package
