diff --git a/fixture-2.0.0.tar.bz2 b/fixture-2.0.0.tar.bz2 new file mode 100644 index 0000000..cce1519 Binary files /dev/null and b/fixture-2.0.0.tar.bz2 differ diff --git a/locate-path-2.0.0.tgz b/locate-path-2.0.0.tgz new file mode 100644 index 0000000..85bdff3 Binary files /dev/null and b/locate-path-2.0.0.tgz differ diff --git a/nodejs-locate-path.spec b/nodejs-locate-path.spec new file mode 100644 index 0000000..23bca31 --- /dev/null +++ b/nodejs-locate-path.spec @@ -0,0 +1,54 @@ +%{?nodejs_find_provides_and_requires} +%global packagename locate-path +%global enable_tests 0 +Name: nodejs-locate-path +Version: 2.0.0 +Release: 1 +Summary: Get the first path that exists on disk of multiple paths +License: MIT +URL: https://github.com/sindresorhus/locate-path +Source0: https://registry.npmjs.org/%{packagename}/-/%{packagename}-%{version}.tgz +#git clone $url +#cd $pkgdir +#git archive --prefix='fixture/' --format=tar ${gittag}:fixture/ \| bzip2 > "$pwd"/fixture-${tag}.tar.bz2 +Source1: fixture-%{version}.tar.bz2 +Source11: https://raw.githubusercontent.com/sindresorhus/locate-path/v%{version}/test.js +ExclusiveArch: %{nodejs_arches} noarch +BuildArch: noarch +BuildRequires: nodejs-packaging npm(p-locate) npm(path-exists) +%if 0%{?enable_tests} +BuildRequires: npm(ava) +%endif +%description +Get the first path that exists on disk of multiple paths + +%prep +%autosetup -n package +%autosetup -T -D -a 1 -n package +cp -p %{SOURCE11} . + +%build + +%install +mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename} +cp -pr package.json index.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 +%doc readme.md +%license license +%{nodejs_sitelib}/%{packagename} + +%changelog +* Mon Aug 17 2020 wutao - 2.0.0-1 +- Package init diff --git a/nodejs-locate-path.yaml b/nodejs-locate-path.yaml new file mode 100644 index 0000000..67b1410 --- /dev/null +++ b/nodejs-locate-path.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: sindresorhus/locate-path +tag_prefix: "^v" +seperator: "." diff --git a/test.js b/test.js new file mode 100644 index 0000000..bd9d3d4 --- /dev/null +++ b/test.js @@ -0,0 +1,21 @@ +import test from 'ava'; +import m from './'; + +const input = [ + 'noop.foo', + 'unicorn.png', + 'index.js', + 'test.js' +]; + +test('async', async t => { + t.is(await m(input), 'index.js'); + t.is(await m(['nonexistant']), undefined); + t.is(await m(['noop', 'unicorn'], {cwd: 'fixture'}), 'unicorn'); +}); + +test('sync', t => { + t.is(m.sync(input), 'index.js'); + t.is(m.sync(['nonexistant']), undefined); + t.is(m.sync(['noop', 'unicorn'], {cwd: 'fixture'}), 'unicorn'); +});