Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}(function(exports) {
"use strict";
/// * `version = transform.version`
/// current version of the transformation algorithm.
exports.version = require("../version").version + " (callbacks - esprima)";
var Syntax = esprima.Syntax;
// ES6 forms that we don't transform yet
// ArrowFunctionExpression = 'ArrowFunctionExpression',
// ClassBody = 'ClassBody',
// ClassDeclaration = 'ClassDeclaration',
// ClassExpression = 'ClassExpression',
// MethodDefinition = 'MethodDefinition',
// ES5 node types that we don't use:
// CatchClause: catch clause inside TryStatement
// DebuggerStatement: debugger
// EmptyStatement: ;
// ObjectExpression: object initializer
// Property: prop: inside ObjectExpression
// WithStatement
/* global -Promise */
'use strict';
var esprima = require('esprima');
var estraverse = require('estraverse');
var Promise = require('promise');
var pathogen = require('pathogen');
var sequence = require('../util/sequence').use(Promise);
var transport = require('../util/transport');
var Resolver = require('../util/resolver');
var isNative = Resolver.isNative;
var Syntax = esprima.Syntax;
var traverse = estraverse.traverse;
var express = function(string) {
return esprima.parse(string).body[0].expression;
};
// Find dependencies in the AST, callback the modified AST.
function requireDependencies(path, tree) {
var self = this;
// Finds valid require and resolve nodes.
var requireNodes = [];
var resolveNodes = [];
traverse(tree, { enter: function(node, parent) {
const test = require("ava");
const esprima = require("esprima");
const Syntax = esprima.Syntax;
const SapUiDefineCall = require("../../../../lib/lbt/calls/SapUiDefine");
function parse(code) {
const ast = esprima.parseScript(code);
return ast.body[0].expression;
}
test("Named Define", (t) => {
const ast = parse("sap.ui.define('HardcodedName', [], function() {});");
const call = new SapUiDefineCall(ast, "FileSystemName");
t.is(call.name, "HardcodedName");
});
test("Unnamed Define", (t) => {
const ast = parse("sap.ui.define([], function() {});");
var assert = require("assert"),
esprimaSyntax = require("esprima").Syntax,
type;
for (type in esprimaSyntax)
exports[type] = esprimaSyntax[type];
function addNonStandardType(type) {
assert.strictEqual(typeof type, "string");
if (exports.hasOwnProperty(type))
assert.strictEqual(exports[type], type);
exports[type] = type;
}
addNonStandardType("File");
addNonStandardType("PropertyPattern");
addNonStandardType("XJSAttribute");
addNonStandardType("XJSIdentifier");
function createLiteral (value) {
return {
type: esprima.Syntax.Literal,
value
};
}
var escodegen = require( "escodegen" );
var esprima = require( "esprima" );
var Syntax = esprima.Syntax;
module.exports = {
test: function( node ) {
return node.type === Syntax.CallExpression &&
node.callee.type === Syntax.MemberExpression &&
node.callee.object.type === Syntax.Identifier &&
node.callee.object.name === "Globalize" &&
node.callee.property.type === Syntax.Identifier &&
node.callee.property.name === "messageFormatter";
},
getFormatterOrParser: function( node ) {
return "Globalize.messageFormatter(" +
escodegen.generate( node.arguments[ 0 ] ) +
")";
}
#!/usr/bin/env node
var esprima = require('esprima');
var escodegen = require('escodegen');
var fs = require('fs');
var Syntax = esprima.Syntax;
var __TRACE__ = '__TRACE__';
/**
* @param {Object} object
* @param {Function} visitor
* @param {Array} path
* @param {Object} state
*/
function traverse(object, path, state) {
var key, child;
if (walker(traverse, object, path, state) === false) {
return;
}
path.unshift(object);
(function(exports) {
if (typeof require !== "function") {
require = function() {};
}
var base = require("./base") || this,
Reserved = require("./reserved"),
util = base.util;
var Syntax = {
Anonymous: "(Anonymous)"
};
for (var key in esprima.Syntax) {
Syntax[key] = esprima.Syntax[key];
}
var Config = Object.create(null);
var Hanlder = {
VariableDeclaration: function(node) {
var self = this;
var declarations = node.declarations;
declarations.forEach(function(d) {
if (d.type == Syntax.VariableDeclarator) {
var name = d.id.name;
var escodegen = require( "escodegen" );
var esprima = require( "esprima" );
var Syntax = esprima.Syntax;
module.exports = {
test: function( node ) {
return node.type === Syntax.CallExpression &&
node.callee.type === Syntax.MemberExpression &&
node.callee.object.type === Syntax.Identifier &&
node.callee.object.name === "Globalize" &&
node.callee.property.type === Syntax.Identifier && (
node.callee.property.name === "currencyFormatter" ||
node.callee.property.name === "dateFormatter" ||
node.callee.property.name === "dateParser" ||
node.callee.property.name === "dateToPartsFormatter" ||
node.callee.property.name === "numberFormatter" ||
node.callee.property.name === "numberParser" ||
node.callee.property.name === "pluralGenerator" ||
node.callee.property.name === "relativeTimeFormatter" ||
* cube: lib/js_processor.js
* support buth js and coffee
* Authors : fish (https://github.com/fishbar)
* Create : 2014-04-18 15:32:20
* CopyRight 2014 (c) Fish And Other Contributors
*/
'use strict';
var debug = require('debug')('cube:processor:js');
var fs = require('fs');
var path = require('path');
var esprima = require('esprima');
var escope = require('escope');
var estraverse = require('estraverse');
var esmangle = require('esmangle');
var codegen = require('escodegen');
var syntax = esprima.Syntax;
var utils = require('./utils');
function getFileName(filepath, ext) {
var filename = path.basename(filepath);
if (ext) {
filename = filename.replace(/\.(\w+)$/, ext);
}
return filename;
}
/** test path .js .coffee */
function tryFiles(cube, root, modPath) {
var origExt = path.extname(modPath);
var fName = path.basename(modPath, origExt);
debug('tryFiles: %s, ext: %s', modPath, origExt);
var dir = path.dirname(modPath);