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 1.1.0 to 1.2.0

lib/minify.js

27

lib/baby-tolk.js
'use strict';
// Polfill Promise for old node versions
require('es6-promise');
var Path = require('path');

@@ -10,4 +7,4 @@ var when = require('when');

var fs = node.liftAll(require('fs'));
var accord = require('accord');
var minify = require('./minify');

@@ -85,2 +82,3 @@ var extensionMap = {};

adapters: loadedAdapters,
isMinifiable: minify.isMinifiable,
read: function (pathName, options) {

@@ -91,3 +89,4 @@ options = options || {};

var adapters = extensionMap[Path.extname(pathName)];
var extension = Path.extname(pathName);
var adapters = extensionMap[extension];
var adapter = adapters && adapters[0];

@@ -106,12 +105,16 @@

var addExtension = function (compiled) {
compiled.extension = adapter.output;
var addInfo = function(compiled) {
compiled.extension = '.' + adapter.output;
compiled.inputPath = pathName;
return when.resolve(compiled);
};
continuation = adapter.renderFile(pathName, transpilerOptions).then(addExtension);
continuation = adapter.renderFile(pathName, transpilerOptions).then(addInfo);
} else {
continuation = fs.readFile(pathName, 'utf8').then(function (source) {
return when.resolve({
result: source
result: source,
extension: extension,
inputPath: pathName
});

@@ -121,4 +124,10 @@ });

if (options.minify) {
continuation = continuation.then(function(compiled) {
return minify(compiled, options);
});
}
return continuation;
}
};
{
"name": "baby-tolk",
"version": "1.1.0",
"version": "1.2.0",
"description": "A file reader that promises to translate non-web assets to web assets given the available transpilers, sourcemaps and all",

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

"accord": "0.20.3",
"clean-css": "3.4.6",
"es6-promise": "3.0.2",
"html-minifier": "1.0.0",
"uglify-js": "2.5.0",
"when": "3.7.3"

@@ -45,0 +48,0 @@ },

@@ -11,3 +11,3 @@ Baby Tolk

Baby Tolk is a "do the right thing" tool for transpiling. It reads a file from the file system, transpiles it (including sourcemaps where supported) with the available transpilers.
Baby Tolk is a "do the right thing" tool for transpiling. It reads a file from the file system, transpiles it (including sourcemaps where supported) with the available transpilers. It can also optionally minify the output.

@@ -30,3 +30,3 @@ Returns a promise that resolves with the resulting transpiler output.

Out of the box this won't transpile anything. In order to do more, for example babel and sass, also do this:
Out of the box this won't transpile anything (but it can minify html, css and JS). In order to do more, for example babel and sass, also do this:

@@ -37,8 +37,8 @@ ```

Now you are ready to start reading files from the file system. Tolk automatically loads the transpilers it has access to in the scope it is run in.
Now you are ready to start reading files from the file system. Baby Tolk automatically loads the transpilers it has access to in the scope it is run in.
```js
var tolk = require('tolk');
```javascript
var babyTolk = require('baby-tolk');
tolk.read('path/to/stylesheet.scss').done(function (compiled) {
babyTolk.read('path/to/stylesheet.scss').then(function (compiled) {
// compiled.result is the transpiled output as a string

@@ -56,3 +56,26 @@ console.log(compiled.result);

Want the output to be minified?
```javascript
babyTolk.read('path/to/stylesheet.scss', {minify: true}).then([success], [fail]);
```
You can also minify vanilla css/js/html files without the transpilation step.
```javascript
babyTolk.read('path/to/app.js', {minify: true}).then([success], [fail]);
```
It's also possible to turn source-maps off.
```javascript
babyTolk.read('path/to/app.js', {sourceMaps: false}).then([success], [fail]);
```
License

@@ -59,0 +82,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