package init

This commit is contained in:
jackie_wu 2020-08-24 13:48:09 +08:00
parent 643a8f307c
commit b8002ddaef
5 changed files with 79 additions and 0 deletions

BIN
fixture-2.0.0.tar.bz2 Normal file

Binary file not shown.

BIN
locate-path-2.0.0.tgz Normal file

Binary file not shown.

54
nodejs-locate-path.spec Normal file
View File

@ -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 <wutao61@huawei.com> - 2.0.0-1
- Package init

4
nodejs-locate-path.yaml Normal file
View File

@ -0,0 +1,4 @@
version_control: github
src_repo: sindresorhus/locate-path
tag_prefix: "^v"
seperator: "."

21
test.js Normal file
View File

@ -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');
});