%{?nodejs_find_provides_and_requires} %global packagename livescript %global enable_tests 1 # Initially, we need to bootstrap the lsc binary to build future versions of # the LiveScript compiler %global bootstrap 1 Name: nodejs-livescript Version: 1.5.0 Release: 1%{?dist} Summary: LiveScript is a language which compiles to JavaScript License: MIT URL: https://github.com/gkz/LiveScript.git Source0: https://registry.npmjs.org/%{packagename}/-/%{packagename}-%{version}.tgz # The test files are not included in the npm tarball. # Source1 is generated by running Source10, which pulls from the upstream # version control repository. Source1: tests-%{version}.tar.bz2 Source2: scripts-%{version}.tar.bz2 Source3: src-%{version}.tar.bz2 Source10: dl-tests.sh # The src directory doesn't contain the source for package.json, so grab it too Source11: https://raw.githubusercontent.com/gkz/LiveScript/%{version}/package.json.ls BuildArch: noarch %if 0%{?fedora} >= 19 ExclusiveArch: %{nodejs_arches} noarch %else ExclusiveArch: %{ix86} x86_64 %{arm} noarch %endif BuildRequires: nodejs-packaging BuildRequires: npm(jison) %if 0%{?enable_tests} BuildRequires: npm(prelude-ls) BuildRequires: npm(optionator) %endif %if !0%{?bootstrap} BuildRequires: npm(LiveScript) %endif %description LiveScript is a language which compiles to JavaScript. It has a straightforward mapping to JavaScript and allows you to write expressive code devoid of repetitive boilerplate. While LiveScript adds many features to assist in functional style programming, it also has many improvements for object oriented and imperative programming. %prep %setup -q -n package # setup the tests %setup -q -T -D -a 1 -n package %setup -q -T -D -a 2 -n package # setup the source files %setup -q -T -D -a 3 -n package # grab package.json.ls cp -p %{SOURCE11} . %nodejs_fixdep optionator '^0.8.1' %build %if !0%{?bootstrap} %{_bindir}/echo -e "\e[102m -=#=- Building from source -=#=- \e[0m" # Build from source # # Symlink the deps early, so that we can build mkdir ./node_modules/ ln -s %{nodejs_sitelib}/jison ./node_modules/jison # Keep a copy of parser.js cp ./lib/parser.js . # Clear the lib/ directory rm -rf ./lib/ mkdir ./lib/ # Next, build package.json from package.json.ls %{_bindir}/lsc --compile package.json.ls # Next, compile the rest of the lib/ directory from the src/ directory %{_bindir}/lsc --output lib --bare --compile src/*.ls # Next, build lib/parser.js %{__nodejs} ./scripts/build-parser > lib/parser.js # Unfortunately, that parser.js file won't work, because we're using a newer # version of 'jison', so copy back the re-built one for now mv ./parser.js ./lib/ # Last but not least, clean up behind ourselves and erase the node_modules/ directory rm -rf ./node_modules/ %endif %install mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename} cp -pr package.json lib/ \ %{buildroot}%{nodejs_sitelib}/%{packagename} mkdir -p %{buildroot}%{nodejs_sitelib}/%{packagename}/bin install -p -D -m0755 bin/lsc %{buildroot}%{nodejs_sitelib}/%{packagename}/bin/lsc mkdir -p %{buildroot}%{_bindir} ln -sf %{nodejs_sitelib}/%{packagename}/bin/lsc \ %{buildroot}%{_bindir}/lsc %nodejs_symlink_deps %check %nodejs_symlink_deps --check %{__nodejs} -e 'require("./")' %if 0%{?enable_tests} %{__nodejs} ./scripts/test %else %{_bindir}/echo -e "\e[101m -=#=- Tests disabled -=#=- \e[0m" %endif %files %{!?_licensedir:%global license %doc} %doc *.md %license LICENSE %{nodejs_sitelib}/%{packagename} %{_bindir}/lsc %changelog * Thu Jul 07 2016 Jared Smith - 1.5.0-1 - Update to upstream 1.5.0 release * Tue Feb 16 2016 Jared Smith - 1.3.1-3 - Fix bootstrapping * Tue Feb 16 2016 Jared Smith - 1.3.1-1 - Initial packaging