Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private static _normalizeDeepestParentFolderPath(folderPath: string): string | undefined {
folderPath = path.normalize(folderPath);
const endsWithSlash: boolean = folderPath.charAt(folderPath.length - 1) === path.sep;
const parsedPath: path.ParsedPath = path.parse(folderPath);
const pathRoot: string = parsedPath.root;
const pathWithoutRoot: string = parsedPath.dir.substr(pathRoot.length);
const pathParts: string[] = [...pathWithoutRoot.split(path.sep), parsedPath.name].filter((part) => !!part);
// Starting with all path sections, and eliminating one from the end during each loop iteration,
// run trueCasePathSync. If trueCasePathSync returns without exception, we've found a subset
// of the path that exists and we've now gotten the correct casing.
//
// Once we've found a parent folder that exists, append the path sections that didn't exist.
for (let i: number = pathParts.length; i >= 0; i--) {
const constructedPath: string = path.join(pathRoot, ...pathParts.slice(0, i));
try {
const normalizedConstructedPath: string = trueCasePathSync(constructedPath);
const result: string = path.join(normalizedConstructedPath, ...pathParts.slice(i));
stringPath = path.normalize(front + back);
} else {
frontArray = frontArray.map(function (key) {
if (key[0] === ":") {
let configKey = key.slice(1);
// replace ':configKey' with config value or return "" if not found
return (config[configKey] || "")
} else {
return key
}
});
stringPath = path.normalize(frontArray.join(path.sep) + back)
}
// replace '$component' with component name or return "" if not found
return path.normalize(stringPath.replace(/\$component/g, name || ""));
}
}
module.exports = function makeHandlerChain(feature, route, routePath, routeInfo, method) {
const arrow = this;
const setting = arrow.arrowSettings;
const featureViews = feature.views;
const featureConfigName = feature.name;
const featureType = feature.type;
if (routeInfo.name) {
arrow._arrRoutes[routeInfo.name] = path.normalize(prefix + routePath);
}
//handle function
let routeHandler;
const defaultHandler = function (req, res, next) {
next(new Error("Invalid controller"));
};
routeHandler = routeInfo.handler;
//TODO: need authenticate
// let authenticate = routeInfo.authenticate ?
// routeInfo.authenticate : false;
// if (!_.isString(authenticate) || !_.isBoolean(authenticate)) {
// return false
// }
// Not full path (No extension(s))
key = path.normalize(path.join(dir, templatePath));
templateData = geddy.templateRegistry[key];
if (templateData) {
break;
}
}
}
// Still no joy
if (!templateData) {
// Is this a Layout?
if (this instanceof Layout) {
// Try to use the default application layout
key = path.normalize('app/views/layouts/application');
templateData = geddy.templateRegistry[key];
// If they've removed the default layout for some reason
if (!templateData) {
throw new Error('Layout template "' + templatePath + '" not found in ' +
utils.array.humanize(dirs));
}
}
// If it's a normal Partial then it doesn't exist, boom
else {
throw new Error('Partial template "' + templatePath + '" not found in ' +
utils.array.humanize(dirs));
}
}
return templateData || null;
};
'use strict';
const LocalstackPlugin = require('../../src/index');
const chai = require('chai');
const expect = require('chai').expect;
const sinon = require('sinon');
const fs = require('fs')
const AWS = require('aws-sdk');
const Serverless = require('serverless')
const AwsProvider = require('serverless/lib/plugins/aws/provider/awsProvider')
const path = require('path');
const localstackEndpointsFile = path.normalize( path.join(__dirname, '../../example/service/localstack_endpoints.json') );
chai.use(require('chai-string'));
// Enable for more verbose logging
const debug = false;
describe("LocalstackPlugin", () => {
let serverless;
let awsProvider;
let awsConfig;
let instance;
let sandbox;
let defaultPluginState = {};
let config = {
host: 'http://localhost',
build() {
// TODO: figure out best way to abstract styling tasks for the builds, should be able to support LESS, Stylus, etc.
const sassBuilder = new SassBuilder({ dist: this.libConfig.dist, sourceMap: false });
const postcssBuilder = new PostCSSBuilder({ dist: this.libConfig.dist, sourceMap: false });
const styles = config.projects[config.project].architect.build.options.styles;
if (ls(path.normalize('tmp/**/*.scss')).length > 0) {
const sassFileList = ls(path.normalize('tmp/**/*.scss'));
(async () => {
const sass = await sassBuilder.batch(sassFileList);
const postcss = await postcssBuilder.batch(sass);
const convert = await this.transformSCSSPathstoCSS();
const bundle = await this.bundleLib();
})();
}
else if (ls(path.normalize('tmp/**/*.css')).length > 0) {
const cssFileList = ls(path.normalize('tmp/**/*.css'));
(async () => {
const postcss = await postcssBuilder.batch(cssFileList);
const bundle = await this.bundleLib();
})();
const iconData = getIconDataSync(name);
data[name] = iconData.pathData;
if (iconData.accData) {
accData[name] = iconData.accData;
}
});
const result = {
collection: collectionName,
data,
accData
}
mkdirp.sync(path.normalize("../../dist/assets/icon-collections/"));
fs.writeFileSync(path.normalize("../../dist/assets/icon-collections/SAP-icons.json"), JSON.stringify(result, 2, 2));
}
_unpackLinux(packagePath){
packagePath = path.normalize(packagePath);
let output = path.dirname(packagePath);
return new Promise((resolve,reject)=>{
execFile(path7za, ['e', packagePath, '-o'+output, '*', '-r', '-y' ], (error, stdout, stderr)=>{
if(error) reject(error);
else resolve();
});
}).then(()=>{
return new Promise((resolve, reject)=>{
let globExpression = packagePath.replace('download.partial','download');
glob(globExpression, (err, matches)=>{
if(err){reject(err); return; }
if(matches.length!==1){ reject(new Error(`Expecting one "tar" file, found ${matches.length}.`)); }
resolve(matches[0]);
});
});
}).then((tarFile)=>{
ROOT: path.normalize(__dirname + "/../../"),
REFERENCE_IMAGES: path.normalize(__dirname + "/../../test/data/ReferenceImages/"),
TEMP: path.normalize(__dirname + "/../../temp/"),
DEPLOY: path.normalize(__dirname + "/../../target/zip/"),
DEPLOY_LIB: path.normalize(__dirname + "/../../target/zip/lib"),
DEPLOY_EXT: path.normalize(__dirname + "/../../target/zip/ext"),
DEPLOY_UI: path.normalize(__dirname + "/../../target/zip/ui-resources/"),
DEPLOY_STYLES: path.normalize(__dirname + "/../../target/zip/ui-resources/styles/"),
TARGET: path.normalize(__dirname + "/../../target/"),
BUILD: path.normalize(__dirname + "/.."),
UNIT_TEST_DEVICE_BUILD: path.normalize(__dirname + "/../../ext"),
UNIT_TEST_SIM_BUILD: path.normalize(__dirname + "/../../ext"),
CLIENTFILES: path.normalize(__dirname + "/../../clientFiles"),
LIB: path.normalize(__dirname + "/../../lib"),
EXT: path.normalize(__dirname + "/../../ext"),
UI: path.normalize(__dirname + "/../../ui-resources"),
UI_PLUGINS: path.normalize(__dirname + "/../../ui-resources/plugins"),
DEPENDENCIES: path.normalize(__dirname + "/../../dependencies"),
DEPENDENCIES_PREPROCESSOR: path.normalize(__dirname + "/../../dependencies/Node-JavaScript-Preprocessor/server.js"),
DEPENDENCIES_BOOTSTRAP: path.normalize(__dirname + "/../../dependencies/bootstrap"),
DEPENDENCIES_JNEXT: path.normalize(__dirname + "/../../dependencies/jnext"),
DEPENDENCIES_REQUIRE: path.normalize(__dirname + "/../../dependencies/require/require.js"),
DEPENDENCIES_CONFIGURE_QSK: path.normalize(__dirname + "/../../dependencies/configure-qsk/configure-qsk"),
NODE_MOD: path.normalize(__dirname + "/../../node_modules"),
COMPILER_THREADS: "4",
USB_IP: "169.254.0.1",
DEFAULT_SSH_KEY: "~/.ssh/id_rsa.pub",
PACKAGE_COMMAND_DEFAULT_PACKAGER: "../target/zip/",
PACKAGE_COMMAND_DEFAULT_APP: "test/test-app/wwtest.zip",
PACKAGE_COMMAND_DEFAULT_OPTIONS: "-d",
DEPLOY_COMMAND_DEFAULT_IP: "169.254.0.1",
DEPLOY_COMMAND_DEFAULT_PW: "qaqa",
var path = require("path");
var rootPath = path.normalize(__dirname + "/..");
module.exports = {
development: {
host: "localhost",
port: 5001,
url: "https://" + this.host + "/" + this.port,
root: rootPath,
app: {
name: "GRNsight"
},
serviceRoot: "//localhost:5000"
},
production: {
host: "grnsight.cs.lmu.edu",
port: 3001,