%{?nodejs_find_provides_and_requires}
Name:                nodejs-iconv
Version:             2.3.4
Release:             1
Summary:             Text recoding in JavaScript for fun and profit
License:             ISC
URL:                 https://github.com/bnoordhuis/node-iconv
Source0:             https://registry.npmjs.org/iconv/-/iconv-%{version}.tgz
Patch0:              nodejs-iconv-safer-buffer.patch
Patch1:              nodejs-iconv-glibc.patch
ExclusiveArch:       %{nodejs_arches}
BuildRequires:       nodejs-devel node-gyp npm(nan) >= 2.2.1 npm(tap)
%{?nodejs_default_filter}
%description
%{summary}.

%prep
%autosetup -p 1 -n package
%nodejs_fixdep --dev --move nan
rm -rf deps support node_modules

%build
%nodejs_symlink_deps --build
export CXXFLAGS="%{optflags}"
export LDFLAGS="%{?__global_ldflags} -Wl,-z,undefs"
node-gyp rebuild -- -Dnode_iconv_use_system_libiconv=1

%install
mkdir -p %{buildroot}%{nodejs_sitearch}/iconv/build/Release
cp -pr package.json lib %{buildroot}%{nodejs_sitearch}/iconv
install -p -m755 build/Release/iconv.node %{buildroot}%{nodejs_sitearch}/iconv/build/Release
%nodejs_symlink_deps

%check
%nodejs_symlink_deps --check
mkdir test/tmp
%{nodejs_sitelib}/tap/bin/tap.js test/test-*.js

%files
%doc README.md
%license LICENSE
%{nodejs_sitearch}/iconv

%changelog
* Thu Aug 20 2020 wangxiao <wangxiao65@huawei.com> - 2.3.4-1
- Package init
