nodejs-acorn/nodejs-acorn.spec
2020-09-09 18:04:48 +08:00

77 lines
2.2 KiB
RPMSpec

%global shortname acorn
%global bootstrap 1
%global enable_tests 1
Name: nodejs-%{shortname}
Version: 5.4.0
Release: 1
Summary: ECMAScript parser
License: MIT
URL: https://github.com/ternjs/acorn
Source0: https://github.com/ternjs/acorn/archive/%{version}.tar.gz
# Source{1-7} are generated by running npm install, example
# tar xvf 5.4.1.tar.gz
# need add patch to fix test errors.
# wget %%{URL}/commit/42f637999c916455f0fbbeb10e2770b00fdf9c41.patch
# patch -p1 <xxx.patch
# cd acron-5.4.1 && npm install
# Source1 in node_modules/acorn/bin
# Source{2-7} in node_modules/acorn/dist
Source1: acorn
Source2: acorn.js
Source3: acorn.es.js
Source4: acorn_loose.js
Source5: acorn_loose.es.js
Source6: walk.js
Source7: walk.es.js
Patch0000: fix-test-errors.patch
BuildArch: noarch
ExclusiveArch: %{nodejs_arches} noarch
BuildRequires: nodejs-packaging npm(rollup)
%description
A tiny, fast JavaScript parser, written completely in JavaScript.
%prep
%autosetup -n acorn-%{version} -p1
cp %{SOURCE1} bin
cp %{SOURCE2} %{SOURCE3} %{SOURCE4} %{SOURCE5} %{SOURCE6} %{SOURCE7} dist
sed -i '1s/env //' bin/acorn
rm dist/.keep
%build
%if 0%{?bootstrap}
%else
%{_bindir}/rollup -c rollup/config.main.js
%{_bindir}/rollup -c rollup/config.walk.js
%{_bindir}/rollup -c rollup/config.loose.js
%{_bindir}/rollup -c rollup/config.bin.js
%endif
%install
mkdir -p %{buildroot}%{nodejs_sitelib}/%{shortname}/
cp -pr package.json bin/ dist/ \
%{buildroot}%{nodejs_sitelib}/%{shortname}
mkdir -p %{buildroot}%{_bindir}
ln -sf %{nodejs_sitelib}/${shortname}/bin/acorn \
%{buildroot}%{_bindir}/${shortname}
%nodejs_symlink_deps
%check
%nodejs_symlink_deps --check
%{__nodejs} -e 'require("./")'
%if 0%{?enable_tests}
%__nodejs test/run.js
%else
%{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m"
%endif
%files
%{!?_licensedir:%global license %doc}
%license LICENSE
%doc README.md
%{nodejs_sitelib}/%{shortname}
%{_bindir}/%{shortname}
%changelog
* Wed Sep 9 2020 Huanghaitao <haunghaitao8@huawei.com> - 5.4.0-1
- Package init