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

@node-minify/core

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@node-minify/core - npm Package Compare versions

Comparing version 7.0.0 to 7.1.0

23

lib/compress.js

@@ -7,11 +7,6 @@ "use strict";

exports.compress = void 0;
var _fs = _interopRequireDefault(require("fs"));
var _mkdirp = _interopRequireDefault(require("mkdirp"));
var _utils = require("@node-minify/utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*!

@@ -36,5 +31,3 @@ * node-minify

}
createDirectory(settings.output);
if (Array.isArray(settings.output)) {

@@ -46,2 +39,3 @@ return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);

};
/**

@@ -52,10 +46,6 @@ * Compress an array of files in sync.

*/
exports.compress = compress;
const compressArrayOfFilesSync = settings => {
return settings.input.forEach((input, index) => {
const content = _utils.utils.getContentFromFiles(input);
return _utils.utils.runSync({

@@ -68,2 +58,3 @@ settings,

};
/**

@@ -74,4 +65,2 @@ * Compress an array of files in async.

*/
const compressArrayOfFilesAsync = settings => {

@@ -81,3 +70,2 @@ let sequence = Promise.resolve();

const content = _utils.utils.getContentFromFiles(input);
sequence = sequence.then(() => _utils.utils.runAsync({

@@ -91,2 +79,3 @@ settings,

};
/**

@@ -97,4 +86,2 @@ * Create folder of the target file.

*/
const createDirectory = file => {

@@ -104,9 +91,6 @@ if (Array.isArray(file)) {

}
const dir = file && file.substr(0, file.lastIndexOf('/'));
if (!dir) {
return;
}
if (!_fs.default.statSync(dir).isDirectory()) {

@@ -116,4 +100,5 @@ _mkdirp.default.sync(dir);

};
/**
* Expose `compress()`.
*/

@@ -7,5 +7,3 @@ "use strict";

exports.compressInMemory = void 0;
var _utils = require("@node-minify/utils");
/*!

@@ -30,10 +28,8 @@ * node-minify

}
return _utils.utils.compressSingleFile(settings);
};
/**
* Expose `compress()`.
*/
exports.compressInMemory = compressInMemory;
"use strict";
var _setup = require("./setup");
var _compress = require("./compress");
var _compressInMemory = require("./compressInMemory");
/*!

@@ -28,3 +25,2 @@ * node-minify

settings = (0, _setup.setup)(settings);
if (!settings.sync) {

@@ -35,3 +31,2 @@ method(settings).then(minified => {

}
resolve(minified);

@@ -42,3 +37,2 @@ }).catch(err => {

}
reject(err);

@@ -48,7 +42,5 @@ });

const minified = method(settings);
if (settings.callback) {
settings.callback(null, minified);
}
resolve(minified);

@@ -58,7 +50,6 @@ }

};
/**
* Expose `minify()`.
*/
module.exports = minify;

65

lib/setup.js

@@ -7,11 +7,6 @@ "use strict";

exports.setup = void 0;
var _path = _interopRequireDefault(require("path"));
var _globby = _interopRequireDefault(require("globby"));
var _utils = require("@node-minify/utils");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*!

@@ -36,2 +31,3 @@ * node-minify

};
/**

@@ -43,6 +39,6 @@ * Run setup.

*/
const setup = inputSettings => {
let settings = Object.assign(_utils.utils.clone(defaultSettings), inputSettings); // In memory
let settings = Object.assign(_utils.utils.clone(defaultSettings), inputSettings);
// In memory
if (settings.content) {

@@ -52,3 +48,2 @@ checkMandatoriesMemoryContent(inputSettings);

}
checkMandatories(inputSettings);

@@ -60,2 +55,3 @@ settings = Object.assign(settings, wildcards(settings.input, settings.publicFolder));

};
/**

@@ -71,9 +67,5 @@ * Check the output path, searching for $1

*/
exports.setup = setup;
const checkOutput = (input, output, publicFolder, replaceInPlace) => {
let reg = new RegExp('\\$1');
if (reg.test(output)) {

@@ -92,2 +84,3 @@ if (Array.isArray(input)) {

};
/**

@@ -100,4 +93,2 @@ * Handle wildcards in a path, get the real path of each files.

*/
const wildcards = (input, publicFolder) => {

@@ -108,5 +99,5 @@ // If it's a string

}
return wildcardsArray(input, publicFolder);
};
/**

@@ -119,13 +110,10 @@ * Handle wildcards in a path (string only), get the real path of each files.

*/
const wildcardsString = (input, publicFolder) => {
const output = {};
if (input.indexOf('*') > -1) {
output.input = getFilesFromWildcards(input, publicFolder);
}
return output;
};
/**

@@ -138,9 +126,8 @@ * Handle wildcards in a path (array only), get the real path of each files.

*/
const wildcardsArray = (input, publicFolder) => {
let output = {};
let isWildcardsPresent = false;
output.input = input; // Transform all wildcards to path file
output.input = input;
// Transform all wildcards to path file
const inputWithPublicFolder = input.map(item => {

@@ -150,11 +137,9 @@ if (item.indexOf('*') > -1) {

}
return (publicFolder || '') + item;
});
if (isWildcardsPresent) {
output.input = _globby.default.sync(inputWithPublicFolder);
} // Remove all wildcards from array
}
// Remove all wildcards from array
for (let i = 0; i < output.input.length; i++) {

@@ -166,5 +151,5 @@ if (output.input[i].indexOf('*') > -1) {

}
return output;
};
/**

@@ -177,13 +162,10 @@ * Get the real path of each files.

*/
const getFilesFromWildcards = (input, publicFolder) => {
let output = [];
if (input.indexOf('*') > -1) {
output = _globby.default.sync((publicFolder || '') + input);
}
return output;
};
/**

@@ -196,13 +178,8 @@ * Prepend the public folder to each file.

*/
const setPublicFolder = (input, publicFolder) => {
let output = {};
if (typeof publicFolder !== 'string') {
return output;
}
publicFolder = _path.default.normalize(publicFolder);
if (Array.isArray(input)) {

@@ -214,3 +191,2 @@ output.input = input.map(item => {

}
return _path.default.normalize(publicFolder + item);

@@ -220,5 +196,5 @@ });

}
input = _path.default.normalize(input);
input = _path.default.normalize(input); // Check if publicFolder is already in path
// Check if publicFolder is already in path
if (input.indexOf(publicFolder) > -1) {

@@ -228,6 +204,6 @@ output.input = input;

}
output.input = _path.default.normalize(publicFolder + input);
return output;
};
/**

@@ -238,7 +214,6 @@ * Check if some settings are here.

*/
const checkMandatories = settings => {
['compressor', 'input', 'output'].forEach(item => mandatory(item, settings));
};
/**

@@ -249,7 +224,6 @@ * Check if some settings are here for memory content.

*/
const checkMandatoriesMemoryContent = settings => {
['compressor', 'content'].forEach(item => mandatory(item, settings));
};
/**

@@ -261,4 +235,2 @@ * Check if the setting exist.

*/
const mandatory = (setting, settings) => {

@@ -269,4 +241,5 @@ if (!settings[setting]) {

};
/**
* Expose `setup()`.
*/
{
"name": "@node-minify/core",
"version": "7.0.0",
"version": "7.1.0",
"description": "core of @node-minify",

@@ -35,7 +35,7 @@ "keywords": [

"dependencies": {
"@node-minify/utils": "^7.0.0",
"@node-minify/utils": "^7.1.0",
"globby": "11.0.4",
"mkdirp": "1.0.4"
},
"gitHead": "8b5bda6f1ac9fe7180006f2a19ec3253e8fff4ec"
"gitHead": "94cef2d5d653c3bddc3e603b4e25c135b0b6f4b3"
}
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