diff --git a/.gitignore b/.gitignore index e69de29..b0a73d8 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +/array-find-index-1.0.1.tgz diff --git a/nodejs-array-find-index.spec b/nodejs-array-find-index.spec new file mode 100644 index 0000000..7d76b5b --- /dev/null +++ b/nodejs-array-find-index.spec @@ -0,0 +1,69 @@ +%{?nodejs_find_provides_and_requires} + +%global packagename array-find-index +# tests disabled until npm(ava) is packaged in Fedora +%global enable_tests 0 + +Name: nodejs-array-find-index +Version: 1.0.1 +Release: 1%{?dist} +Summary: ES2015 `Array#findIndex()` ponyfill + +License: MIT +URL: https://github.com/sindresorhus/array-find-index +Source0: https://registry.npmjs.org/%{packagename}/-/%{packagename}-%{version}.tgz +# The test files are not included in the npm tarball. +Source1: https://raw.githubusercontent.com/sindresorhus/array-find-index/v%{version}/test.js + + +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: npm(ava) +%endif + +%description +ES2015 `Array#findIndex()` ponyfill + + +%prep +%autosetup -n package +# setup the tests +cp -p %{SOURCE1} . + + +%build +# nothing to do + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename} +cp -pr package.json *.js \ + %{buildroot}%{nodejs_sitelib}/%{packagename} + +%nodejs_symlink_deps + +%check +%nodejs_symlink_deps --check +%{__nodejs} -e 'require("./")' +%if 0%{?enable_tests} +%{_bindir}/ava +%else +%{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m" +%endif + +%files +%{!?_licensedir:%global license %doc} +%doc *.md +%license license +%{nodejs_sitelib}/%{packagename} + +%changelog +* Sat Jul 16 2016 Jared Smith - 1.0.1-1 +- Initial packaging diff --git a/sources b/sources index e69de29..3a8ed97 100644 --- a/sources +++ b/sources @@ -0,0 +1 @@ +591030ce56142e321e0881358a19fd65 array-find-index-1.0.1.tgz diff --git a/test.js b/test.js new file mode 100644 index 0000000..7945cb1 --- /dev/null +++ b/test.js @@ -0,0 +1,11 @@ +/* eslint-disable no-extend-native */ +Array.prototype.findIndex = undefined; +import test from 'ava'; +import fn from './'; + +const f = [10, 20, 30, 40]; + +test(t => { + t.is(fn(f, x => x === 30), 2); + t.is(fn(f, x => x === 'noop'), -1); +});