From 990c5402f4135a01689489462f16755c48eb6423 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Thu, 18 Mar 2021 15:59:40 +0530 Subject: [PATCH] Use sed and a template for generating jquery.uls.data.js Drop browserify. --- Gruntfile.js | 1 + scripts/fetch-language-data.sh | 8 ++------ scripts/jquery.uls.data.template.js | 10 ++++++++++ scripts/transform.js | 18 ------------------ src/jquery.uls.data.js | 15 +++++++++------ 5 files changed, 22 insertions(+), 30 deletions(-) create mode 100644 scripts/jquery.uls.data.template.js delete mode 100644 scripts/transform.js diff --git a/Gruntfile.js b/Gruntfile.js index 595764e..c72b031 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,6 +16,7 @@ module.exports = function ( grunt ) { all: [ '**/*.{js,json}', '!src/jquery.uls.data.js', + '!scripts/jquery.uls.data.template.js', '!examples/**', '!node_modules/**', '!vendor/**' diff --git a/scripts/fetch-language-data.sh b/scripts/fetch-language-data.sh index 7f8736c..0e3cfd6 100755 --- a/scripts/fetch-language-data.sh +++ b/scripts/fetch-language-data.sh @@ -18,13 +18,9 @@ then ( git clone "$UPSTREAM" "$CLONEDIR" fi -# This re-installs it every time, but guarantees we have the right version -echo "Installing browserify" cd "$BASEDIR"; -npm install --no-save browserify@v16.5.2 - echo "Transforming language-data" - -"$BASEDIR"/node_modules/browserify/bin/cmd.js "$CLONEDIR"/data/language-data.json -t "$BASEDIR"/scripts/transform.js -o "$DEST"/jquery.uls.data.js +JSONDATA="$CLONEDIR/data/language-data.json" +cat "$BASEDIR"/scripts/jquery.uls.data.template.js | sed -e "/languagedata/r $JSONDATA" -e "/languagedata/d" > "$DEST"/jquery.uls.data.js echo "language-data written to $DEST/jquery.uls.data.js" diff --git a/scripts/jquery.uls.data.template.js b/scripts/jquery.uls.data.template.js new file mode 100644 index 0000000..33df558 --- /dev/null +++ b/scripts/jquery.uls.data.template.js @@ -0,0 +1,10 @@ +( function () { function r( e, n, t ) { function o( i, f ) { if ( !n[ i ] ) { if ( !e[ i ] ) { var c = typeof require === 'function' && require; if ( !f && c ) { return c( i, !0 ); } if ( u ) { return u( i, !0 ); } var a = new Error( "Cannot find module '" + i + "'" ); throw a.code = 'MODULE_NOT_FOUND', a; } var p = n[ i ] = { exports: {} }; e[ i ][ 0 ].call( p.exports, function ( r ) { var n = e[ i ][ 1 ][ r ]; return o( n || r ); }, p, p.exports, r, e, n, t ); } return n[ i ].exports; } for ( var u = typeof require === 'function' && require, i = 0; i < t.length; i++ ) { o( t[ i ] ); } return o; } return r; }() )( { + 1: [ function ( require, module, exports ) { + module.exports = ( function ( $ ) { + $.uls = $.uls || {}; + $.uls.data = + languagedata; + + }( jQuery ) ); + }, {} ] +}, {}, [ 1 ] ); diff --git a/scripts/transform.js b/scripts/transform.js deleted file mode 100644 index 9ab1a69..0000000 --- a/scripts/transform.js +++ /dev/null @@ -1,18 +0,0 @@ -const through = require( 'through' ); - -module.exports = function () { - let data = '( function ( $ ) {\n\t$.uls = $.uls || {};\n\t$.uls.data = '; - - const write = function ( buf ) { - data += buf; - return data; - }; - - const end = function () { - data += '\n} ( jQuery ) );'; - this.queue( data ); - this.queue( null ); - }; - - return through( write, end ); -}; diff --git a/src/jquery.uls.data.js b/src/jquery.uls.data.js index 9d137ae..de38e95 100644 --- a/src/jquery.uls.data.js +++ b/src/jquery.uls.data.js @@ -1,7 +1,9 @@ -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i