[MediaWiki-commits] [Gerrit] mediawiki...cxserver[master]: Include scripts in bin folder for eslint and make it pass tests
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/382377 ) Change subject: Include scripts in bin folder for eslint and make it pass tests .. Include scripts in bin folder for eslint and make it pass tests Change-Id: Ib63491db26d5fc660b5d646779825fdf46b395cd --- M bin/linearize M bin/mt M bin/segment M test/index.js 4 files changed, 20 insertions(+), 18 deletions(-) Approvals: jenkins-bot: Verified Nikerabbit: Looks good to me, approved diff --git a/bin/linearize b/bin/linearize index 5dc027c..0118b9e 100755 --- a/bin/linearize +++ b/bin/linearize @@ -1,11 +1,10 @@ #!/usr/bin/env node -var script, xhtml, parser, - fs = require( 'fs' ), +const fs = require( 'fs' ), LinearDoc = require( __dirname + '/../lib/lineardoc' ); -xhtml = fs.readFileSync( '/dev/stdin', 'utf8' ); +const xhtml = fs.readFileSync( '/dev/stdin', 'utf8' ); if ( xhtml.trim() === '' ) { - script = process.argv[ 1 ]; + const script = process.argv[ 1 ]; process.stderr.write( 'Usage: node ' + script + ' < file\n' + 'Input must be wrapped in a block element such as ... or ...\n' @@ -14,7 +13,7 @@ } -parser = new LinearDoc.Parser( new LinearDoc.MwContextualizer() ); +const parser = new LinearDoc.Parser( new LinearDoc.MwContextualizer() ); parser.init(); parser.write( xhtml ); process.stdout.write( parser.builder.doc.dumpXml() ); diff --git a/bin/mt b/bin/mt index 4796cf5..b365f33 100755 --- a/bin/mt +++ b/bin/mt @@ -5,7 +5,7 @@ const config = yaml.load( fs.readFileSync( 'config.yaml' ) ); if ( !config ) { - console.error( 'Failed to load config' ); + process.stderr.write( 'Failed to load config' ); process.exit( 1 ); } const cxConfig = config.services && Array.isArray( config.services ) && @@ -13,7 +13,7 @@ return item && item.name === 'cxserver'; } )[ 0 ]; if ( !cxConfig ) { - console.error( 'Cannot find cxserver config' ); + process.stderr.write( 'Cannot find cxserver config' ); process.exit( 1 ); } @@ -42,7 +42,7 @@ } if ( !MTClients[ mtService ] ) { - console.error( `Cannot find MT service: ${mtService}` ); + process.stderr.write( `Cannot find MT service: ${mtService}` ); process.exit( 1 ); } @@ -56,9 +56,9 @@ process.stdout.write( targetHtml + '\n' ); } ).catch( ( error ) => { if ( error.stack ) { - console.error( 'error', error.stack ); + process.stderr.write( error.stack ); } else { - console.error( 'error', error ); + process.stderr.write( error ); } process.exit( 2 ); } ); diff --git a/bin/segment b/bin/segment index 31da4b2..c32dc2a 100755 --- a/bin/segment +++ b/bin/segment @@ -1,19 +1,18 @@ #!/usr/bin/env node -var script, xhtmlSource, xhtml, result, segmenter, - fs = require( 'fs' ), +const fs = require( 'fs' ), Segmenter = require( __dirname + '/../lib/segmentation/CXSegmenter' ), LinearDoc = require( __dirname + '/../lib/lineardoc' ); function normalize( html ) { - var normalizer = new LinearDoc.Normalizer(); + const normalizer = new LinearDoc.Normalizer(); normalizer.init(); normalizer.write( html.replace( /(\r\n|\n|\t|\r)/gm, '' ) ); return normalizer.getHtml(); } -html = fs.readFileSync( '/dev/stdin', 'utf8' ); +const html = fs.readFileSync( '/dev/stdin', 'utf8' ); if ( html.trim() === '' ) { - script = process.argv[ 1 ]; + const script = process.argv[ 1 ]; process.stderr.write( 'Usage: node ' + script + ' < file\n' + 'Input must be wrapped in a block element such as ... or ...\n' @@ -22,7 +21,7 @@ } -segmenter = new Segmenter( html, 'en' ); +const segmenter = new Segmenter( html, 'en' ); segmenter.segment(); -result = normalize( segmenter.getSegmentedContent() ); +const result = normalize( segmenter.getSegmentedContent() ); process.stdout.write( result + '\n' ); diff --git a/test/index.js b/test/index.js index eaa94e6..2dec3d5 100644 --- a/test/index.js +++ b/test/index.js @@ -7,7 +7,11 @@ paths = [ 'lib/*.js', 'lib/**/*.js', - 'test/**/*.js' + 'test/**/*.js', + 'bin/mt', + 'bin/adapt', + 'bin/linearize', + 'bin/segment' ]; // Run the tests -- To view, visit https://gerrit.wikimedia.org/r/382377 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib63491db26d5fc660b5d646779825fdf46b395cd Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/services/cxserver Gerrit-Branch: master Gerrit-Owner: SanthoshGerrit-Reviewer: Nikerabbit Gerrit-Reviewer: Santhosh Gerrit-Reviewer: jenkins-bot <>
[MediaWiki-commits] [Gerrit] mediawiki...cxserver[master]: Include scripts in bin folder for eslint and make it pass tests
Santhosh has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/382377 ) Change subject: Include scripts in bin folder for eslint and make it pass tests .. Include scripts in bin folder for eslint and make it pass tests Change-Id: Ib63491db26d5fc660b5d646779825fdf46b395cd --- M bin/linearize M bin/mt M bin/segment M test/index.js 4 files changed, 20 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver refs/changes/77/382377/1 diff --git a/bin/linearize b/bin/linearize index 5dc027c..0118b9e 100755 --- a/bin/linearize +++ b/bin/linearize @@ -1,11 +1,10 @@ #!/usr/bin/env node -var script, xhtml, parser, - fs = require( 'fs' ), +const fs = require( 'fs' ), LinearDoc = require( __dirname + '/../lib/lineardoc' ); -xhtml = fs.readFileSync( '/dev/stdin', 'utf8' ); +const xhtml = fs.readFileSync( '/dev/stdin', 'utf8' ); if ( xhtml.trim() === '' ) { - script = process.argv[ 1 ]; + const script = process.argv[ 1 ]; process.stderr.write( 'Usage: node ' + script + ' < file\n' + 'Input must be wrapped in a block element such as ... or ...\n' @@ -14,7 +13,7 @@ } -parser = new LinearDoc.Parser( new LinearDoc.MwContextualizer() ); +const parser = new LinearDoc.Parser( new LinearDoc.MwContextualizer() ); parser.init(); parser.write( xhtml ); process.stdout.write( parser.builder.doc.dumpXml() ); diff --git a/bin/mt b/bin/mt index 4796cf5..e20ff8e 100755 --- a/bin/mt +++ b/bin/mt @@ -5,7 +5,7 @@ const config = yaml.load( fs.readFileSync( 'config.yaml' ) ); if ( !config ) { - console.error( 'Failed to load config' ); + process.stderr.write( 'Failed to load config' ); process.exit( 1 ); } const cxConfig = config.services && Array.isArray( config.services ) && @@ -13,7 +13,7 @@ return item && item.name === 'cxserver'; } )[ 0 ]; if ( !cxConfig ) { - console.error( 'Cannot find cxserver config' ); + process.stderr.write( 'Cannot find cxserver config' ); process.exit( 1 ); } @@ -42,7 +42,7 @@ } if ( !MTClients[ mtService ] ) { - console.error( `Cannot find MT service: ${mtService}` ); + process.stderr.write( `Cannot find MT service: ${mtService}` ); process.exit( 1 ); } @@ -56,9 +56,9 @@ process.stdout.write( targetHtml + '\n' ); } ).catch( ( error ) => { if ( error.stack ) { - console.error( 'error', error.stack ); + process.stderr.write( 'error', error.stack ); } else { - console.error( 'error', error ); + process.stderr.write( 'error', error ); } process.exit( 2 ); } ); diff --git a/bin/segment b/bin/segment index 31da4b2..c32dc2a 100755 --- a/bin/segment +++ b/bin/segment @@ -1,19 +1,18 @@ #!/usr/bin/env node -var script, xhtmlSource, xhtml, result, segmenter, - fs = require( 'fs' ), +const fs = require( 'fs' ), Segmenter = require( __dirname + '/../lib/segmentation/CXSegmenter' ), LinearDoc = require( __dirname + '/../lib/lineardoc' ); function normalize( html ) { - var normalizer = new LinearDoc.Normalizer(); + const normalizer = new LinearDoc.Normalizer(); normalizer.init(); normalizer.write( html.replace( /(\r\n|\n|\t|\r)/gm, '' ) ); return normalizer.getHtml(); } -html = fs.readFileSync( '/dev/stdin', 'utf8' ); +const html = fs.readFileSync( '/dev/stdin', 'utf8' ); if ( html.trim() === '' ) { - script = process.argv[ 1 ]; + const script = process.argv[ 1 ]; process.stderr.write( 'Usage: node ' + script + ' < file\n' + 'Input must be wrapped in a block element such as ... or ...\n' @@ -22,7 +21,7 @@ } -segmenter = new Segmenter( html, 'en' ); +const segmenter = new Segmenter( html, 'en' ); segmenter.segment(); -result = normalize( segmenter.getSegmentedContent() ); +const result = normalize( segmenter.getSegmentedContent() ); process.stdout.write( result + '\n' ); diff --git a/test/index.js b/test/index.js index eaa94e6..2dec3d5 100644 --- a/test/index.js +++ b/test/index.js @@ -7,7 +7,11 @@ paths = [ 'lib/*.js', 'lib/**/*.js', - 'test/**/*.js' + 'test/**/*.js', + 'bin/mt', + 'bin/adapt', + 'bin/linearize', + 'bin/segment' ]; // Run the tests -- To view, visit https://gerrit.wikimedia.org/r/382377 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib63491db26d5fc660b5d646779825fdf46b395cd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/cxserver Gerrit-Branch: master Gerrit-Owner: Santhosh___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org