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

baby-tolk

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baby-tolk - npm Package Compare versions

Comparing version 4.3.0 to 4.4.0

65

lib/baby-tolk.js

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

var Path = require('path');
var when = require('when');
var node = require('when/node');

@@ -14,2 +13,3 @@ var fs = node.liftAll(require('fs'));

var pathCompleteExtname = require('path-complete-extname');
var crypto = require('crypto');
var minify = require('./minify');

@@ -103,2 +103,8 @@

var createHash = function(data) {
var shasum = crypto.createHash('sha1');
shasum.update(data);
return shasum.digest('hex');
};
module.exports = {

@@ -121,2 +127,6 @@ get extensions() {

options.sourceMap = options.sourceMap === false ? false : true;
if (options.sha) {
options.inputSha = true;
options.outputSha = true;
}

@@ -127,7 +137,17 @@ var extension = pathCompleteExtname(pathName);

var continuation;
var file = fs.readFile(pathName, 'utf8');
var continuation = file.then(function(result) {
var obj = { result: result };
if (options.inputSha) { obj.inputSha = createHash(result); }
return obj;
});
var transformId = '';
if (adapter) {
transformId = adapter.engineName + '@' + adapter.engine.version;
var transpilerOptions = Object.assign({}, options, {
sourcemap: options.sourceMap
sourcemap: options.sourceMap,
filename: pathName
});

@@ -139,25 +159,28 @@

var addInfo = function(compiled) {
compiled.extension = '.' + adapter.output;
compiled.inputPath = pathName;
return when.resolve(compiled);
};
continuation = continuation.then(function(source) {
return adapter.render(source.result, transpilerOptions)
.then(function(compiled) {
compiled.extension = '.' + adapter.output;
compiled.inputPath = pathName;
if (options.inputSha) { compiled.inputSha = source.inputSha; }
return compiled;
});
});
continuation = adapter.renderFile(pathName, transpilerOptions).then(addInfo);
} else {
continuation = fs.readFile(pathName, 'utf8').then(function (source) {
return when.resolve({
result: source,
extension: extension,
inputPath: pathName
});
continuation = continuation.then(function(source) {
source.extension = extension;
source.inputPath = pathName;
return source;
});
}
if (options.minify) {
continuation = continuation.then(function(compiled) {
return minify(compiled, options);
});
}
continuation.then(function(compiled) {
if (options.minify) { compiled = minify(compiled, options); }
if (options.outputSha) { compiled.outputSha = createHash(compiled.result); }
if (compiled.sourcemap) { transformId += '::map'; }
if (compiled.minified) { transformId += '::minify'; }
compiled.transformId = transformId === '' ? null : transformId;
return compiled;
});

@@ -164,0 +187,0 @@ return continuation;

@@ -107,3 +107,6 @@ 'use strict';

compiled = html(compiled);
} else {
return compiled;
}
compiled.minified = true;
if (!options.sourceMap) {

@@ -110,0 +113,0 @@ compiled.sourcemap = null;

{
"name": "baby-tolk",
"version": "4.3.0",
"version": "4.4.0",
"description": "A file reader that promises to translate non-web assets to web assets given the available transpilers, sourcemaps and all",

@@ -44,3 +44,3 @@ "main": "lib/baby-tolk.js",

"clean-css": "^3.4.18",
"html-minifier": "^2.1.3",
"html-minifier": "3.0.3",
"path-complete-extname": "0.1.0",

@@ -64,3 +64,3 @@ "uglify-js": "^2.7.0",

"marked": "^0.3.5",
"mocha": "^2.3.4",
"mocha": "3.0.2",
"mocha-lcov-reporter": "^1.0.0",

@@ -71,4 +71,4 @@ "myth": "^1.5.0",

"swig": "^1.4.2",
"unexpected": "10.13.3"
"unexpected": "10.17.2"
}
}
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