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

karma-json-fixtures-preprocessor

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karma-json-fixtures-preprocessor - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

29

json_fixtures.js
module.exports = (function () {
'use strict';
var util = require('util'),
TEMPLATE = '' +
'window.__fixtures__ = window.__fixtures__ || {};\n' +
'window.__fixtures__[\'%s\'] = %s;\n';
var util = require('util');
function createJsonFixturesPreprocessor(basePath) {
function getTemplate(varName) {
varName = varName ? varName : '__fixtures__';
return 'window.' + varName + ' = window.' + varName + ' || {};\n' +
'window.' + varName + '[\'%s\'] = %s;\n';
}
function createJsonFixturesPreprocessor(basePath, config) {
config = typeof config === 'object' ? config : {};
var stripPrefix = new RegExp('^' + (config.stripPrefix || '')),
prependPrefix = config.prependPrefix || '';
return function (content, file, done) {

@@ -15,11 +24,17 @@ var fixtureName = file.originalPath

// Set the template
var template = getTemplate(config.variableName);
// Update the fixture name
fixtureName = prependPrefix + fixtureName.replace(stripPrefix, '');
file.path = file.path.replace(/\.json$/, '.js');
done(util.format(TEMPLATE, fixtureName, content));
done(util.format(template, fixtureName, content));
};
}
createJsonFixturesPreprocessor.$inject = ['config.basePath'];
createJsonFixturesPreprocessor.$inject = ['config.basePath', 'config.jsonFixturesPreprocessor'];
return createJsonFixturesPreprocessor;
})();
{
"name": "karma-json-fixtures-preprocessor",
"version": "0.0.0",
"version": "0.0.1",
"description": "A Karma plugin to compile JSON files and make them accessible from Javascript code",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -27,3 +27,11 @@ karma-json-fixtures-preprocessor

'./fixtures/**/*.json'
]
],
jsonFixturesPreprocessor: {
// strip this from the file path \ fixture name
stripPrefix: 'test/fixtures',
// strip this to the file path \ fixture name
prependPrefix: 'mock/',
// change the global fixtures variable name
variableName: '__mocks__'
}
});

@@ -30,0 +38,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