New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@bestest/compiler

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bestest/compiler - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

46

lib/Compiler.js

@@ -6,2 +6,3 @@ "use strict";

var FileSystem_1 = require("@bestest/fs/lib/FileSystem");
var createDelayedFunction_1 = require("@bestest/utils/lib/createDelayedFunction");
var buildOptions_1 = require("@bestest/utils/lib/buildOptions");

@@ -66,13 +67,12 @@ var assign_1 = require("@bestest/utils/lib/assign");

Compiler.prototype.initialize = function (callback) {
var _this = this;
this.events.emit('initialize:start');
// Delay functions, to ensure that their errors will not affect the flow
var emit = createDelayedFunction_1.createDelayedFunction(this.events.emit.bind(this.events));
var call = createDelayedFunction_1.createDelayedFunction(callback);
// Inform about initialization process started
emit('initialize:start');
// Emit result back
var onFinish = function (error) {
_this.events.emit('initialize:end', error);
if (error === null) {
_this.events.emit('initialize:success');
}
else {
_this.events.emit('initialize:error', error);
}
callback(error || null);
emit('initialize:end', error);
emit(error === null ? 'initialize:success' : 'initialize:error', error);
call(error || null);
};

@@ -84,5 +84,3 @@ // Handle synchronous errors and initialize adapter

catch (error) {
this.events.emit('initialize:end', error);
this.events.emit('initialize:error', error);
callback(error);
onFinish(error || new Error());
}

@@ -98,3 +96,5 @@ };

Compiler.prototype.compile = function (options, callback) {
var _this = this;
// Delay functions, to ensure that their errors will not affect the flow
var emit = createDelayedFunction_1.createDelayedFunction(this.events.emit.bind(this.events));
var call = createDelayedFunction_1.createDelayedFunction(callback);
// Validate callback

@@ -121,13 +121,8 @@ if (typeof callback !== 'function') {

// Emit 'start' event
this.events.emit('compile:start', { compiler: compiler, options: finalOptions });
emit('compile:start', { compiler: compiler, options: finalOptions });
// Wrap callback, to emit finish events
var onFinish = function (error, fs, entries) {
_this.events.emit('compile:end', { compiler: compiler, error: error, fs: fs, entries: entries });
if (error === null) {
_this.events.emit('compile:success', { compiler: compiler, fs: fs, entries: entries });
}
else {
_this.events.emit('compile:error', { error: error, compiler: compiler });
}
callback(error, fs, entries);
emit('compile:end', { compiler: compiler, error: error, fs: fs, entries: entries });
emit(error === null ? 'compile:success' : 'compile:error', { compiler: compiler, error: error, fs: fs, entries: entries });
call(error, fs, entries);
};

@@ -139,6 +134,3 @@ // Handle synchronous errors in adapter compilation process

catch (error) {
var finalError = { error: error, filePath: null, details: null };
this.events.emit('compile:end', { compiler: compiler, error: error, fs: null, entries: null });
this.events.emit('compile:error', { error: error, compiler: compiler });
onFinish(finalError, null, null);
onFinish({ error: error || new Error(), filePath: null, details: null }, null, null);
}

@@ -145,0 +137,0 @@ };

@@ -5,2 +5,3 @@ import * as path from 'path'

import { FileSystem } from '@bestest/fs/lib/FileSystem'
import { createDelayedFunction } from '@bestest/utils/lib/createDelayedFunction'
import { buildOptions } from '@bestest/utils/lib/buildOptions'

@@ -90,14 +91,15 @@ import { assign } from '@bestest/utils/lib/assign'

initialize (callback: (error: any | null) => any) {
this.events.emit('initialize:start')
// Delay functions, to ensure that their errors will not affect the flow
const emit = createDelayedFunction(this.events.emit.bind(this.events))
const call = createDelayedFunction(callback)
// Inform about initialization process started
emit('initialize:start')
// Emit result back
const onFinish = (error: any | null) => {
this.events.emit('initialize:end', error)
emit('initialize:end', error)
emit(error === null ? 'initialize:success' : 'initialize:error', error)
if (error === null) {
this.events.emit('initialize:success')
} else {
this.events.emit('initialize:error', error)
}
callback(error || null)
call(error || null)
}

@@ -109,6 +111,3 @@

} catch (error) {
this.events.emit('initialize:end', error)
this.events.emit('initialize:error', error)
callback(error)
onFinish(error || new Error())
}

@@ -125,2 +124,6 @@ }

compile (options: Partial<CompilerCompileOptionsInterface>, callback: CompilerCallbackType) {
// Delay functions, to ensure that their errors will not affect the flow
const emit = createDelayedFunction(this.events.emit.bind(this.events))
const call = createDelayedFunction(callback)
// Validate callback

@@ -151,3 +154,3 @@ if (typeof callback !== 'function') {

// Emit 'start' event
this.events.emit('compile:start', { compiler, options: finalOptions })
emit('compile:start', { compiler, options: finalOptions })

@@ -160,11 +163,6 @@ // Wrap callback, to emit finish events

) => {
this.events.emit('compile:end', { compiler, error, fs, entries })
emit('compile:end', { compiler, error, fs, entries })
emit(error === null ? 'compile:success' : 'compile:error', { compiler, error, fs, entries })
if (error === null) {
this.events.emit('compile:success', { compiler, fs, entries })
} else {
this.events.emit('compile:error', { error, compiler })
}
callback(error, fs, entries)
call(error, fs, entries)
}

@@ -176,8 +174,3 @@

} catch (error) {
const finalError = { error, filePath: null, details: null }
this.events.emit('compile:end', { compiler, error, fs: null, entries: null })
this.events.emit('compile:error', { error, compiler })
onFinish(finalError, null, null)
onFinish({ error: error || new Error(), filePath: null, details: null }, null, null)
}

@@ -184,0 +177,0 @@ }

@@ -23,3 +23,3 @@ import { CompilerAdapterCompileOptionsInterface } from './interfaces/CompilerAdapterCompileOptionsInterface';

*
* @param {function} callback
* @param {function(*)} callback
*/

@@ -26,0 +26,0 @@ initialize(callback: (error: any | null) => any): void;

@@ -21,3 +21,3 @@ "use strict";

*
* @param {function} callback
* @param {function(*)} callback
*/

@@ -24,0 +24,0 @@ CompilerAdapter.prototype.initialize = function (callback) {

@@ -33,3 +33,3 @@ import { buildOptions } from '@bestest/utils/lib/buildOptions'

*
* @param {function} callback
* @param {function(*)} callback
*/

@@ -36,0 +36,0 @@ initialize (callback: (error: any | null) => any) {

@@ -15,3 +15,2 @@ import { CompilerAdapterCompileOptionsInterface } from './CompilerAdapterCompileOptionsInterface'

/** Compile passed files */
// TODO: FIX callback TYPE
compile (options: Partial<CompilerAdapterCompileOptionsInterface>, callback: CompilerCallbackType): void

@@ -18,0 +17,0 @@ }

@@ -23,3 +23,2 @@ import { EventEmitter } from 'events'

/** Compile passed files */
// TODO: FIX callback TYPE
compile (options: Partial<CompilerCompileOptionsInterface>, callback: CompilerCallbackType): void

@@ -26,0 +25,0 @@ }

{
"name": "@bestest/compiler",
"version": "1.0.1",
"version": "1.0.2",
"description": "Compiler part of Bestest benchmarking tool - compile your code in memory to run on different environments.",

@@ -13,3 +13,3 @@ "publishConfig": {

"build": "npm run clean && tsc -p ./tsconfig.json",
"lint": "tslint -p ./tsconfig.json -c tslint.json",
"lint": "tslint -p ./tsconfig.json -c ../../tslint.json",
"ts-check": "tsc -p ./tsconfig.json --noEmit",

@@ -58,4 +58,4 @@ "test": "npm run ts-check && npm run lint",

"@bestest/time-measurement": "^1.0.1",
"@bestest/utils": "^1.0.0"
"@bestest/utils": "^1.1.1"
}
}

@@ -80,3 +80,4 @@ # @bestest/compiler

* **1.0.2** (on 2019-08-14): delay events & callbacks, to ensure that flow will work even despite errors
* **1.0.1** (on 2019-08-09): fix Webpack adapter link in README file
* **1.0.0** (on 2019-08-09): initial version
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