1 |
%{?nodejs_find_provides_and_requires} |
2 |
|
3 |
%global enable_tests 0 |
4 |
|
5 |
# This package requires the grunt stack, but grunt also requires this package. |
6 |
# Before grunt is available, this will need to be built manually. |
7 |
%global enable_grunt 0 |
8 |
|
9 |
Name: nodejs-hooker |
10 |
Version: 0.2.3 |
11 |
Release: %mkrel 1 |
12 |
Summary: Monkey-patch (hook) functions for debugging |
13 |
License: MIT |
14 |
Group: Development/Other |
15 |
URL: https://github.com/cowboy/javascript-hooker |
16 |
Source0: http://registry.npmjs.org/hooker/-/hooker-%{version}.tgz |
17 |
|
18 |
# This is taken from the upstream version control repository. |
19 |
Patch0: %{name}-0.2.3-Updating-gruntfile-to-grunt-0.3.0-format.patch |
20 |
# These two patches update grunt.js for use with grunt 0.4.0. |
21 |
# Pull request sent: https://github.com/cowboy/javascript-hooker/pull/3 |
22 |
Patch1: %{name}-0.2.3-Rename-grunt.js-to-Gruntfile.js.patch |
23 |
Patch2: %{name}-0.2.3-Update-Gruntfile.js-for-use-with-grunt-0.4.0.patch |
24 |
|
25 |
BuildArch: noarch |
26 |
ExclusiveArch: noarch |
27 |
|
28 |
BuildRequires: nodejs-packaging |
29 |
BuildRequires: uglify-js |
30 |
|
31 |
%if 0%{?enable_tests} |
32 |
BuildRequires: npm(nodeunit) |
33 |
%endif |
34 |
|
35 |
%if 0%{?enable_grunt} |
36 |
BuildRequires: npm(grunt-cli) |
37 |
BuildRequires: npm(grunt-contrib-nodeunit) |
38 |
BuildRequires: npm(grunt-contrib-uglify) |
39 |
%endif |
40 |
|
41 |
%description |
42 |
%{summary}. |
43 |
|
44 |
|
45 |
%prep |
46 |
%setup -q -n package |
47 |
%patch0 -p1 |
48 |
%patch1 -p1 |
49 |
%patch2 -p1 |
50 |
%nodejs_symlink_deps --check |
51 |
|
52 |
|
53 |
%build |
54 |
%if 0%{?enable_grunt} |
55 |
grunt uglify |
56 |
%else |
57 |
# Add copyright header to the minified script. |
58 |
head -n 8 lib/hooker.js > dist/ba-hooker.min.js.new |
59 |
# Minify and preserve timestamp. |
60 |
/usr/bin/uglifyjs dist/ba-hooker.js -m -c >> dist/ba-hooker.min.js.new |
61 |
touch -r dist/ba-hooker.min.js dist/ba-hooker.min.js.new |
62 |
mv dist/ba-hooker.min.js{.new,} |
63 |
%endif |
64 |
|
65 |
|
66 |
%install |
67 |
mkdir -p %{buildroot}%{nodejs_sitelib}/hooker |
68 |
cp -pr package.json child.js dist/ lib/ parent.js \ |
69 |
%{buildroot}%{nodejs_sitelib}/hooker |
70 |
|
71 |
%nodejs_symlink_deps |
72 |
|
73 |
|
74 |
%if 0%{?enable_tests} |
75 |
%check |
76 |
%if 0%{?enable_grunt} |
77 |
grunt nodeunit |
78 |
%else |
79 |
%{nodejs_sitelib}/nodeunit/bin/nodeunit test/*.js |
80 |
%endif |
81 |
%endif |
82 |
|
83 |
|
84 |
%files |
85 |
%doc LICENSE-MIT README.md |
86 |
%{nodejs_sitelib}/hooker |