%{?nodejs_find_provides_and_requires}
%global enable_tests 1
Name:                nodejs-esprima
Version:             2.7.2
Release:             2
Summary:             ECMAScript parsing infrastructure for multipurpose analysis
License:             BSD
URL:                 https://github.com/jquery/esprima
Source0:             https://github.com/jquery/esprima/archive/%{version}/%{name}-%{version}.tar.gz
BuildArch:           noarch
ExclusiveArch:       %{nodejs_arches} noarch
BuildRequires:       nodejs-packaging
BuildRequires:       npm(glob) npm(json-diff) npm(lodash)
%description
%{summary}.

%prep
%autosetup -n esprima-%{version}

%build

%install
mkdir -p %{buildroot}%{nodejs_sitelib}/esprima
cp -pr package.json esprima.js \
    %{buildroot}%{nodejs_sitelib}/esprima
mkdir -p %{buildroot}%{_bindir}
for i in esparse.js esvalidate.js; do
    install -p -D -m0755 bin/${i} %{buildroot}%{nodejs_sitelib}/esprima/bin/${i}
    ln -s %{nodejs_sitelib}/esprima/bin/${i} %{buildroot}%{_bindir}/${i}
done
%nodejs_symlink_deps
%if 0%{?enable_tests}

%check
%nodejs_symlink_deps --check
%__nodejs tools/generate-fixtures.js
%__nodejs test/unit-tests.js
%__nodejs test/regression-tests.js
%endif

%files
%doc README.md ChangeLog
%license LICENSE.BSD
%{nodejs_sitelib}/esprima
%{_bindir}/esparse.js
%{_bindir}/esvalidate.js

%changelog
* Thu Nov 26 2020 leiju <leiju4@huawei.com> - 2.7.2-2
- delete nodejs-esprima.spec.old redundancy file

* Thu Aug 20 2020 Anan Fu <fuanan3@huawei.com> - 2.7.2-1
- package init
