diff --git a/nodejs-resolve-pkg.spec b/nodejs-resolve-pkg.spec new file mode 100644 index 0000000..f6ae36d --- /dev/null +++ b/nodejs-resolve-pkg.spec @@ -0,0 +1,52 @@ +%{?nodejs_find_provides_and_requires} +%global packagename resolve-pkg +%global enable_tests 0 +Name: nodejs-resolve-pkg +Version: 1.0.0 +Release: 1 +Summary: Resolve the path of a package regardless of it having an entry +License: MIT +URL: https://github.com/sindresorhus/resolve-pkg +Source0: https://registry.npmjs.org/%{packagename}/-/%{packagename}-%{version}.tgz +Source1: https://raw.githubusercontent.com/sindresorhus/resolve-pkg/v%{version}/test.js +BuildArch: noarch +ExclusiveArch: %{nodejs_arches} noarch +BuildRequires: nodejs-packaging npm(resolve-from) + +%if 0%{?enable_tests} +BuildRequires: npm(ava) +%endif +%description +Resolve the path of a package regardless of it having an entry + +%prep +%autosetup -n package +cp -p %{SOURCE1} . +%nodejs_fixdep resolve-from + +%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 +%{!?_licensedir:%global license %doc} +%doc *.md +%license license +%{nodejs_sitelib}/%{packagename} + +%changelog +* Wed Aug 19 2020 wangyue - 1.0.0-1 +- package init diff --git a/nodejs-resolve-pkg.yaml b/nodejs-resolve-pkg.yaml new file mode 100644 index 0000000..eb6843a --- /dev/null +++ b/nodejs-resolve-pkg.yaml @@ -0,0 +1,5 @@ +git_url: https://github.com/sindresorhus/resolve-pkg +version_control: github +src_repo: sindresorhus/resolve-pkg +tag_prefix: "^v" +seperator: "." diff --git a/resolve-pkg-1.0.0.tgz b/resolve-pkg-1.0.0.tgz new file mode 100644 index 0000000..d952397 Binary files /dev/null and b/resolve-pkg-1.0.0.tgz differ diff --git a/test.js b/test.js new file mode 100644 index 0000000..ea331d9 --- /dev/null +++ b/test.js @@ -0,0 +1,12 @@ +import path from 'path'; +import test from 'ava'; +import m from './'; + +test(t => { + t.is(m('nonexistent'), null); + t.is(m('nonexistent/foo'), null); + t.is(path.relative('.', m('grunt-svgmin')), 'node_modules/grunt-svgmin'); + t.is(path.relative('.', m('grunt-svgmin/tasks')), 'node_modules/grunt-svgmin/tasks'); + t.is(path.relative('.', m('@someprivate/module-test')), 'node_modules/@someprivate/module-test'); + t.is(path.relative('.', m('@someprivate/module-test/subdir')), 'node_modules/@someprivate/module-test/subdir'); +});