Files
add-and-commit/node_modules/@node-minify/babel-minify/lib/babel-minify.js
Federico Grandi f118062594 Update with working working version (#12)
* Fix workflow

* Trigger

* [auto] Update compiled version

* [auto] Commit modules

* Push Windows changes

* Fix

* [auto] Update compiled version

* Try removing cwd

* [auto] Update compiled version

* Try with path module

* [auto] Update compiled version

* Fix path

* [auto] Update compiled version

* Use raw path

* [auto] Update compiled version

* Other path

* [auto] Update compiled version

* Avoid @action/exec

* [auto] Update compiled version

* test

* [auto] Update compiled version

* test

* [auto] Update compiled version

* test

* [auto] Update compiled version

* test

* [auto] Update compiled version

* Try with shelljs

* [auto] Update compiled version

* Fix my stupidity

* Copy scripts to local dir

* [auto] Update compiled version

* Still use path

* [auto] Update compiled version

* Delete entrypoint.sh

* [auto] Update compiled version

* Make file executable

* [auto] Update compiled version

* Try using bash

* [auto] Update compiled version
2019-12-14 21:47:13 +01:00

70 lines
1.4 KiB
JavaScript

"use strict";
var _babelCore = require("babel-core");
var _babelPresetMinify = _interopRequireDefault(require("babel-preset-minify"));
var _utils = require("@node-minify/utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*!
* node-minify
* Copyright(c) 2011-2019 Rodolphe Stoclin
* MIT Licensed
*/
/**
* Module dependencies.
*/
/**
* Run babel-minify.
*
* @param {Object} settings
* @param {String} content
* @param {Function} callback
*/
const minifyBabel = ({
settings,
content,
callback,
index
}) => {
let babelOptions = {
presets: []
};
if (settings.options.babelrc) {
babelOptions = JSON.parse(_utils.utils.readFile(settings.options.babelrc));
}
if (settings.options.presets) {
const babelrcPresets = babelOptions.presets || [];
babelOptions.presets = babelrcPresets.concat(settings.options.presets);
}
if (babelOptions.presets.indexOf('minify') === -1) {
babelOptions.presets = babelOptions.presets.concat([_babelPresetMinify.default]);
}
const contentMinified = (0, _babelCore.transform)(content, babelOptions);
_utils.utils.writeFile({
file: settings.output,
content: contentMinified.code,
index
});
if (callback) {
return callback(null, contentMinified.code);
}
return contentMinified.code;
};
/**
* Expose `minifyBabel()`.
*/
module.exports = minifyBabel;