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

babel-d

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-d - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

41

lib/babel-compile.js

@@ -41,5 +41,15 @@ 'use strict';

* compile files
* @return {} []
*
* @param {String} srcPath
* @param {String} outPath
* @param {Object} [options]
* @param {String} [options.debug] only for debug
*/
function compile(srcPath, outPath) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
if (options.debug) {
console.log('\nBegin compile...', srcPath, outPath, options);
}
var files = getFiles(srcPath, true);

@@ -49,3 +59,5 @@

console.log(files);
if (options.debug) {
console.log('all files:', files);
}

@@ -55,8 +67,11 @@ files.forEach(function (file) {

var saveOutFullPathpath = path.join(outPath, file);
var extname = path.extname(file);
if (options.debug) {
console.log('[' + extname + '] ' + srcFullPath + ' => ' + saveOutFullPathpath);
}
//if is not js file, only copy
if (allowFileExt.indexOf(extname) === -1) {
compileFile(srcFullPath, saveOutFullPathpath, true);
compileFile(srcFullPath, saveOutFullPathpath, true, options);
return;

@@ -78,3 +93,3 @@ }

if (!compiledMtime[file] || mTime > compiledMtime[file]) {
var ret = compileFile(srcFullPath, saveOutFullPathpath);
var ret = compileFile(srcFullPath, saveOutFullPathpath, false, options);

@@ -106,7 +121,12 @@ if (ret) {

* compile single file
* @param {String} file []
* @param {Boolean} [onlyCopy] []
* @return {} []
*
* @param {String} srcFullPath
* @param {String} saveOutFullPath
* @param {Boolean} [onlyCopy]
* @param {Object} [options]
* @param {String} [options.debug] only for debug
*/
function compileFile(srcFullPath, saveOutFullPath, onlyCopy) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var content = fs.readFileSync(srcFullPath, 'utf8');

@@ -135,4 +155,7 @@

var endTime = Date.now();
console.log('Compile file ' + srcFullPath, 'Babel cost ' + (endTime - startTime));
if (options.debug) {
console.log('Compile file ' + srcFullPath, 'Babel cost ' + (endTime - startTime) + ' ms');
}
// save file

@@ -139,0 +162,0 @@ fse.outputFileSync(saveOutFullPath, data.code);

{
"name": "babel-d",
"version": "0.1.4",
"version": "0.1.5",
"description": "compile directories by babel using in node",

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

@@ -26,5 +26,13 @@ const fs = require('fs');

* compile files
* @return {} []
*
* @param {String} srcPath
* @param {String} outPath
* @param {Object} [options]
* @param {String} [options.debug] only for debug
*/
export function compile(srcPath, outPath) {
export function compile(srcPath, outPath, options = {}) {
if (options.debug) {
console.log('\nBegin compile...', srcPath, outPath, options);
}
let files = getFiles(srcPath, true);

@@ -34,3 +42,5 @@

console.log(files);
if (options.debug) {
console.log('all files:', files);
}

@@ -40,8 +50,11 @@ files.forEach(file => {

let saveOutFullPathpath = path.join(outPath, file);
let extname = path.extname(file);
if (options.debug) {
console.log(`[${extname}] ${srcFullPath} => ${saveOutFullPathpath}`);
}
//if is not js file, only copy
if (allowFileExt.indexOf(extname) === -1) {
compileFile(srcFullPath, saveOutFullPathpath, true);
compileFile(srcFullPath, saveOutFullPathpath, true, options);
return;

@@ -63,3 +76,3 @@ }

if (!compiledMtime[file] || mTime > compiledMtime[file]) {
let ret = compileFile(srcFullPath, saveOutFullPathpath);
let ret = compileFile(srcFullPath, saveOutFullPathpath, false, options);

@@ -91,7 +104,10 @@ if (ret) {

* compile single file
* @param {String} file []
* @param {Boolean} [onlyCopy] []
* @return {} []
*
* @param {String} srcFullPath
* @param {String} saveOutFullPath
* @param {Boolean} [onlyCopy]
* @param {Object} [options]
* @param {String} [options.debug] only for debug
*/
export function compileFile(srcFullPath, saveOutFullPath, onlyCopy) {
export function compileFile(srcFullPath, saveOutFullPath, onlyCopy, options = {}) {
let content = fs.readFileSync(srcFullPath, 'utf8');

@@ -120,4 +136,7 @@

let endTime = Date.now();
console.log(`Compile file ${srcFullPath}`, `Babel cost ${endTime - startTime}`);
if (options.debug) {
console.log(`Compile file ${srcFullPath}`, `Babel cost ${endTime - startTime} ms`);
}
// save file

@@ -124,0 +143,0 @@ fse.outputFileSync(saveOutFullPath, data.code);

Sorry, the diff of this file is not supported yet

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