%{?nodejs_find_provides_and_requires}

%global enable_tests 1

Name:                nodejs-requirejs
Version:             2.1.11
Release:             1
Summary:             Node.js adapter for RequireJS, for loading AMD modules
License:             MIT or BSD
URL:                 https://github.com/jrburke/r.js
Source0:             https://github.com/jrburke/r.js/archive/%{version}.tar.gz
Patch0000:           0001-fix-package.json-make-the-rpm-can-provides-npm-requi.patch
BuildArch:           noarch
ExclusiveArch:       %{nodejs_arches} noarch
BuildRequires:       nodejs-packaging

%description
RequireJS is a JavaScript file and module loader. It is optimized for
in-browser use, but it can be used in other JavaScript environments,
like Rhino and Node. Using a modular script loader like RequireJS will
improve the speed and quality of your code.


%prep
%autosetup -p1 -n r.js-%{version}


%build


%install
mkdir -p %{buildroot}%{nodejs_sitelib}/requirejs
cp -pr package.json require.js \
    %{buildroot}%{nodejs_sitelib}/requirejs
mkdir -p %{buildroot}%{nodejs_sitelib}/requirejs/bin
install -p -D -m0755 dist/r.js \
    %{buildroot}%{nodejs_sitelib}/requirejs/bin/r.js

mkdir -p %{buildroot}%{_bindir}
ln -s %{nodejs_sitelib}/requirejs/bin/r.js \
    %{buildroot}%{_bindir}/r.js

%nodejs_symlink_deps


%if 0%{?enable_tests}
%check
pushd tests/
%__nodejs ../dist/r.js all.js
popd
%endif


%files
%doc LICENSE README.md
%{nodejs_sitelib}/requirejs
%{_bindir}/r.js


%changelog
* Wed Aug 19 2020 wangxiao <wangxiao65@huawei.com> - 2.1.11-1
- package init
