Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gettext-extractor-vue

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gettext-extractor-vue - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

fixtures/attributes_again.vue

52

fixtures/all.vue.json
[
{
"text":
"\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n Praesent tempus metus vitae arcu vestibulum, vitae dictum lorem ullamcorper.\nNam pharetra mauris enim, ut posuere metus efficitur sit amet.\n ",
"text": "\n Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n Praesent tempus metus vitae arcu vestibulum, vitae dictum lorem ullamcorper.\nNam pharetra mauris enim, ut posuere metus efficitur sit amet.\n ",
"textPlural": null,

@@ -32,2 +31,16 @@ "context": null,

{
"text": "Branch has changed",
"textPlural": null,
"context": null,
"references": ["fixtures/attributes_again.vue:2"],
"comments": []
},
{
"text": "Create new branch",
"textPlural": null,
"context": null,
"references": ["fixtures/attributes_again.vue:2"],
"comments": []
},
{
"text": "event",

@@ -78,3 +91,38 @@ "textPlural": null,

"comments": []
},
{
"text": "Stage all changes",
"textPlural": null,
"context": null,
"references": ["fixtures/attributes_again.vue:3"],
"comments": []
},
{
"text": "Staged",
"textPlural": null,
"context": null,
"references": ["fixtures/attributes_again.vue:3"],
"comments": []
},
{
"text": "This branch has changed since you started editing.\n Would you like to create a new branch?",
"textPlural": null,
"context": null,
"references": ["fixtures/attributes_again.vue:2"],
"comments": []
},
{
"text": "Unstage all changes",
"textPlural": null,
"context": null,
"references": ["fixtures/attributes_again.vue:3"],
"comments": []
},
{
"text": "Unstaged",
"textPlural": null,
"context": null,
"references": ["fixtures/attributes_again.vue:3"],
"comments": []
}
]

2

index.js
const extractSnippets = require('./lib/extractSnippets');
const decorateJSParserWithVueSupport = require('./lib/decorateJSParserWithVueSupport');
const decorateExtractorWithHelpers = require('./lib/decorateExtractorWithHelpers');
const ensureSingleLine = require('./lib/ensureSingleLine');

@@ -10,3 +9,2 @@ module.exports = {

decorateExtractorWithHelpers,
ensureSingleLine,
};

@@ -14,3 +14,2 @@ 'use strict';

decorateExtractorWithHelpers,
ensureSingleLine,
} = require('./index');

@@ -135,5 +134,5 @@ const fs = require('fs');

describe('ensureSingleLineMessages', () => {
it('should remove unnecessary new lines from extractor.addMessage', () => {
extractor.ensureSingleLineMessages();
describe('addMessageTransformFunction', () => {
it('should apply transform function to extractor.addMessage', () => {
extractor.addMessageTransformFunction(() => 'FOO');

@@ -147,4 +146,4 @@ extractor.addMessage({

{
text: 'Test',
textPlural: 'Plural spans multiple lines.',
text: 'FOO',
textPlural: 'FOO',
context: null,

@@ -157,4 +156,4 @@ references: [],

it('should remove unnecessary new lines from parser.parseString', () => {
extractor.ensureSingleLineMessages();
it('should apply transform function to parser.parseString', () => {
extractor.addMessageTransformFunction(() => 'FOO');

@@ -174,4 +173,4 @@ const jsParser = extractor.createJsParser([

{
text: 'Test message',
textPlural: ' Plural',
text: 'FOO',
textPlural: 'FOO',
context: null,

@@ -188,3 +187,3 @@ references: ['a.js:1'],

should.throws(() => {
extractor.ensureSingleLineMessages();
extractor.addMessageTransformFunction(() => 'FOO');
}, /^Error: Make sure you run ensureSingleLineMessages/);

@@ -194,33 +193,1 @@ });

});
describe('ensureSingleLine', () => {
it('should remove newlines at the start of the string', () => {
const result = 'Test';
should(ensureSingleLine(`\n${result}`)).equal(result);
should(ensureSingleLine(`\t\n\t${result}`)).equal(result);
should(ensureSingleLine(`\r\n${result}`)).equal(result);
should(ensureSingleLine(`\r\n ${result}`)).equal(result);
should(ensureSingleLine(`\r ${result}`)).equal(result);
should(ensureSingleLine(` \n ${result}`)).equal(result);
});
it('should remove newlines at the end of the string', () => {
const result = 'Test';
should(ensureSingleLine(`${result}\n`)).equal(result);
should(ensureSingleLine(`${result}\t\n\t`)).equal(result);
should(ensureSingleLine(`${result}\r\n`)).equal(result);
should(ensureSingleLine(`${result}\r`)).equal(result);
should(ensureSingleLine(`${result} \r`)).equal(result);
should(ensureSingleLine(`${result} \r\n `)).equal(result);
});
it('should replace newlines in the middle of the string with a single space', () => {
const result = 'Test';
should(ensureSingleLine(`${result}\n${result}`)).equal(`${result} ${result}`);
should(ensureSingleLine(`${result}\t\n\t${result}`)).equal(`${result} ${result}`);
should(ensureSingleLine(`${result}\r\n${result}`)).equal(`${result} ${result}`);
should(ensureSingleLine(`${result}\r${result}`)).equal(`${result} ${result}`);
should(ensureSingleLine(`${result} \r${result}`)).equal(`${result} ${result}`);
should(ensureSingleLine(`${result} \r\n ${result}`)).equal(`${result} ${result}`);
});
});
const decorateExtractorWithHelpers = extractor => {
extractor.ensureSingleLineMessages = () => {
if (extractor.$ensuredSingleLine) {
extractor.addMessageTransformFunction = fn => {
if (extractor.$overwrittenBuilder) {
return;
}
const SingleLineCatalogBuilder = require('./singleLineCatalogBuilder');
const TransformLineCatalogBuilder = require('./transformLineCatalogBuilder');
extractor.builder = new TransformLineCatalogBuilder(extractor.builder, fn);
extractor.builder = new SingleLineCatalogBuilder(extractor.builder);
extractor.$ensuredSingleLine = true;
extractor.$overwrittenBuilder = true;
};

@@ -12,0 +11,0 @@

{
"name": "gettext-extractor-vue",
"version": "3.0.1",
"version": "4.0.0",
"description": "Extend gettext-extractor with the possibility to parse `.vue` files",

@@ -15,8 +15,8 @@ "main": "index.js",

"devDependencies": {
"gettext-extractor": "^3.3.0",
"gettext-extractor": "^3.3.2",
"husky": "^0.14.3",
"mocha": "^5.2.0",
"prettier": "^1.13.4",
"prettier": "^1.14.0",
"pretty-quick": "^1.6.0",
"should": "^13.2.1"
"should": "^13.2.3"
},

@@ -29,4 +29,4 @@ "peerDependencies": {

"glob": "5 - 7",
"vue-template-compiler": "^2.5.16"
"vue-template-compiler": "^2.5.17"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc