git: b248aa163e80 - main - www/csso: Fix a runtime error

From: Nicola Vitale <nivit_at_FreeBSD.org>
Date: Sun, 27 Nov 2022 14:06:32 UTC
The branch main has been updated by nivit:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b248aa163e80a73ba4955042a30994d948cc9c3d

commit b248aa163e80a73ba4955042a30994d948cc9c3d
Author:     Nicola Vitale <nivit@FreeBSD.org>
AuthorDate: 2022-11-27 14:04:21 +0000
Commit:     Nicola Vitale <nivit@FreeBSD.org>
CommitDate: 2022-11-27 14:05:17 +0000

    www/csso: Fix a runtime error
    
    - Add a temporary patch to fix the following error:
    
    /usr/local/share/csso/lib/csso.js:69
        print(fs.readFileSync(__dirname.slice(0, __dirname.lastIndexOf('/')) + '/' + filename).toString());
        ^
    
    TypeError: print is not a function
        at printFile (/usr/local/share/csso/lib/csso.js:69:5)
        at Object.<anonymous> (/usr/local/share/csso/lib/csso.js:28:5)
        at Module._compile (internal/modules/cjs/loader.js:1236:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)
        at Module.load (internal/modules/cjs/loader.js:1085:32)
        at Function.Module._load (internal/modules/cjs/loader.js:950:14)
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
        at internal/main/run_main_module.js:17:47
    
    This happens because the function util.print() has been removed by recent
    versions of node.
    
    - Install the file VERSION (required when using --version switch)
    - Reorder variables in Makefile
    - Bump PORTREVISION (pkg-plist changed)
    
    PR:     268010
    Reported by:    Chris Hutchinson <portmaster@bsdforge.com>
---
 www/csso/Makefile                | 10 ++++------
 www/csso/files/patch-lib_csso.js | 12 ++++++++++++
 www/csso/pkg-plist               |  1 +
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/www/csso/Makefile b/www/csso/Makefile
index 699bdf877942..d5b5817d8611 100644
--- a/www/csso/Makefile
+++ b/www/csso/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	csso
 PORTVERSION=	1.3.9
 DISTVERSIONPREFIX=	v
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	www
 MASTER_SITES=	http://nivit.altervista.org/FreeBSD/ports/distfiles/
 
@@ -13,17 +13,15 @@ LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/MIT-LICENSE.txt
 
 USES=		nodejs:run
-
+USE_GITHUB=	yes
 GH_ACCOUNT=	css
 
-NO_BUILD=	yes
 NO_ARCH=	yes
-
-USE_GITHUB=	yes
+NO_BUILD=	yes
 
 do-install:
 	@${MKDIR} ${STAGEDIR}${DATADIR}/bin
-	${INSTALL_DATA} ${WRKSRC}/USAGE ${STAGEDIR}${DATADIR}/USAGE
+	${INSTALL_DATA} ${WRKSRC}/USAGE ${WRKSRC}/VERSION ${STAGEDIR}${DATADIR}/
 	${INSTALL_SCRIPT} ${WRKSRC}/bin/${PORTNAME} ${STAGEDIR}${DATADIR}/bin/${PORTNAME}
 	${LN} -sf ${DATADIR}/bin/${PORTNAME} ${STAGEDIR}/${PREFIX}/bin/${PORTNAME}
 	cd ${WRKSRC}/lib && ${COPYTREE_SHARE} . ${STAGEDIR}${DATADIR}/lib
diff --git a/www/csso/files/patch-lib_csso.js b/www/csso/files/patch-lib_csso.js
new file mode 100644
index 000000000000..351f7f49219f
--- /dev/null
+++ b/www/csso/files/patch-lib_csso.js
@@ -0,0 +1,12 @@
+--- lib/csso.js.orig	2013-10-15 12:47:12 UTC
++++ lib/csso.js
+@@ -1,7 +1,8 @@
+ var fs = require('fs'),
+-    print = require('util').print,
+     csso = require('./cssoapi.js'),
+     src, x;
++
++var print = console.log;
+ 
+ var args = process.argv.slice(2),
+     opts = args.length ? getOpts(args, [
diff --git a/www/csso/pkg-plist b/www/csso/pkg-plist
index 4e4e4088f436..90ab0302900e 100644
--- a/www/csso/pkg-plist
+++ b/www/csso/pkg-plist
@@ -1,5 +1,6 @@
 bin/csso
 %%DATADIR%%/USAGE
+%%DATADIR%%/VERSION
 %%DATADIR%%/bin/csso
 %%DATADIR%%/lib/compressor.js
 %%DATADIR%%/lib/csso.js