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

easygettext

Package Overview
Dependencies
Maintainers
6
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easygettext - npm Package Compare versions

Comparing version 2.9.0 to 2.10.0

3

package.json
{
"name": "easygettext",
"version": "2.9.0",
"version": "2.10.0",
"description": "Simple tools to extract gettext strings",

@@ -38,2 +38,3 @@ "main": "src/extract-cli.js",

"cheerio": "^1.0.0-rc.3",
"codecov": "^3.6.5",
"flow-remove-types": "^1.2.3",

@@ -40,0 +41,0 @@ "minimist": "^1.2.0",

@@ -70,17 +70,3 @@ #!/usr/bin/env node

extractor.parse(file, extract.preprocessTemplate(data, ext));
let lang = 'js';
if (ext === 'vue') {
const script = extract.preprocessVueFile(data);
if (script) {
data = script.content;
lang = script.lang;
} else {
lang = null;
}
}
if (lang === 'js') {
extractor.parseJavascript(file, data);
}
extractor.parseJavascript(file, extract.preprocessJavascript(data, ext));
} catch (e) {

@@ -87,0 +73,0 @@ console.error(`[${PROGRAM_NAME}] could not read: '${filename}`);

@@ -54,11 +54,14 @@ const cheerio = require('cheerio');

function preprocessVueFile(data) {
const vueFile = vueCompiler.parse({ compiler, source: data, needMap: false });
if (!vueFile.script) {
return null;
function preprocessJavascript(data, type) {
let scriptData = '';
switch (type) {
case 'vue':
const vueFile = vueCompiler.parse({ compiler, source: data, needMap: false });
if (!vueFile.script) return '';
scriptData = vueFile.script.content.trim();
break;
default:
break;
}
return {
content: vueFile.script.content.trim(),
lang: vueFile.script.lang || 'js',
};
return scriptData;
}

@@ -89,3 +92,3 @@

exports.preprocessTemplate = preprocessTemplate;
exports.preprocessVueFile = preprocessVueFile;
exports.preprocessJavascript = preprocessJavascript;

@@ -92,0 +95,0 @@ exports.NodeTranslationInfo = class NodeTranslationInfo {

@@ -124,25 +124,22 @@ const extract = require('./extract.js');

it('should preprocess VueJS script tag correctly', () => {
const script = extract.preprocessVueFile(fixtures.VUE_COMPONENT_WITH_SCRIPT_TAG);
const script = extract.preprocessJavascript(fixtures.VUE_COMPONENT_WITH_SCRIPT_TAG, 'vue');
expect(script.content).toEqual(fixtures.VUE_COMPONENT_EXPECTED_PROCESSED_SCRIPT_TAG);
expect(script.lang).toEqual('js');
expect(script).toEqual(fixtures.VUE_COMPONENT_EXPECTED_PROCESSED_SCRIPT_TAG);
});
it('should preprocess VueJS no script tag correctly', () => {
const script = extract.preprocessVueFile(fixtures.VUE_COMPONENT_WITHOUT_SCRIPT_TAG);
const script = extract.preprocessJavascript(fixtures.VUE_COMPONENT_WITHOUT_SCRIPT_TAG, 'vue');
expect(script).toBe(null);
expect(script).toBe('');
});
it('should preprocess VueJS script tag in TypeScript correctly', () => {
const script = extract.preprocessVueFile(fixtures.VUE_COMPONENT_WITH_TS_SCRIPT_TAG);
const script = extract.preprocessJavascript(fixtures.VUE_COMPONENT_WITH_TS_SCRIPT_TAG, 'vue');
expect(script.content).toEqual(fixtures.VUE_COMPONENT_EXPECTED_PROCESSED_TS_SCRIPT_TAG);
expect(script.lang).toEqual('ts');
expect(script).toEqual(fixtures.VUE_COMPONENT_EXPECTED_PROCESSED_TS_SCRIPT_TAG);
});
it('should preprocess VueJS script tag with Flow', () => {
const script = extract.preprocessVueFile(fixtures.VUE_COMPONENT_WITH_FLOW_SCRIPT_TAG);
expect(script.content).toEqual(fixtures.VUE_COMPONENT_EXPECTED_PROCESSED_FLOW_SCRIPT_TAG);
expect(script.lang).toEqual('js');
const script = extract.preprocessJavascript(fixtures.VUE_COMPONENT_WITH_FLOW_SCRIPT_TAG, 'vue');
expect(script).toEqual(fixtures.VUE_COMPONENT_EXPECTED_PROCESSED_FLOW_SCRIPT_TAG);
});

@@ -149,0 +146,0 @@ });

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