Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
global.window = win
const hasOwnProperty = {}.hasOwnProperty
function propagateToGlobal(window: Object) {
for (let key in window) { // eslint-disable-line
if (hasOwnProperty.call(window, key) && !(key in global)) {
global[key] = window[key]
}
}
}
propagateToGlobal(win)
glob.sync(__dirname + '/spec/**/*.js').forEach((file) => require(file)) // eslint-disable-line
function prepareService() {
// search for service jar
let foundFiles = glob.sync(serviceBuild);
if(foundFiles.length !== 1) {
console.error('Error while searching for service build file.');
}
fs.createReadStream(foundFiles[0]).pipe(fs.createWriteStream(path.join(__dirname, 'workspace-service.jar')));
}
function loadRouter(app, root, options) {
const opt = options || {};
glob.sync(`${root}/**/*.js`).forEach((file) => {
const realRoot = os.platform() === 'win32' ? root.replace(/\\/ig, '/') : root;
const filePath = file.replace(/\.[^.]*$/, '');
const controller = require(filePath);
const urlPrefix = filePath.replace(realRoot, '').replace(/\/index$/, '');
const methods = Object.keys(controller);
// Handle options
const excludeRules = opt.excludeRules || [];
const rewriteRules = opt.rewriteRules || new Map();
function applyMethod(name, methodBody) {
const body = methodBody;
let modifiedUrl = `${urlPrefix}${name === 'index' ? '' : `/${name}`}`;
let middlewares = [];
let method = 'get';
let handler;
ModulesDiscover.prototype.discover = function() {
var modulePaths;
// TODO: Already we support only plugins/*.
modulePaths = glob.sync(fs.realpathSync(this.project.getPath()) + '/src/plugins/*/');
if (this.project.isPro()) {
modulePaths = modulePaths.concat(glob.sync(fs.realpathSync(this.project.getPath()) + '/node_modules/handsontable/src/plugins/*/'));
}
modulePaths.forEach(function(modulePath) {
// Searching only js files (ignoring tests).
var files = glob.sync('**/*(@([^_]*).js)', {
cwd: modulePath,
ignore: ['test/**'],
}).map(function(fileName) {
return path.resolve(path.join(modulePath, fileName));
});
var item = new ItemDescriptor({
path: modulePath,
files: files,
});
this.discoveredModules.push(item);
function addFiles(mocha, files) {
files = (typeof files === 'string') ? glob.sync(root + files) : files;
files.forEach(mocha.addFile.bind(mocha));
}
gulp.task('assets', function() {
console.log('\nListing all the assets files in the project...'.yellow);
var assets = glob.sync(basePath + '/**/assets.*.*.json');
assets.forEach(function(asset) {
console.log(asset.replace(basePath, ''));
});
console.log('{0} files found\n'.format(assets.length).yellow);
});
}
const imagesPath = prefix + "images"
if (fs.existsSync(imagesPath)) {
const imageFiles = glob.sync(prefix + "images/*")
for (let file of imageFiles) {
if (!file.endsWith("ionicons.ttf")) {
console.log("unlinking ", file)
fs.unlinkSync(file)
}
}
} else {
console.log("No folder at", imagesPath)
}
const maps = glob.sync(prefix + "*.js.map")
for (let file of maps) {
console.log("unlinking ", file)
fs.unlinkSync(file)
}
const indexHtmlPath = prefix + "index.html"
if (fs.existsSync(indexHtmlPath)) {
fs.unlinkSync(indexHtmlPath)
console.log("rm ", indexHtmlPath)
} else {
console.log("no file at", indexHtmlPath)
}
}
function _getCollectionFragments(collectionDirectory) {
return glob
.sync(path.join(collectionDirectory, '*', 'fragment.json'))
.map(
/** @param {string} fragmentJSON */
fragmentJSON => path.resolve(fragmentJSON, '..')
)
.filter(directory => {
try {
_readJSONSync(path.resolve(directory, 'fragment.json'));
return true;
} catch (error) {
log(`✘ Invalid ${directory}/fragment.json, fragment ignored`, {
level: 'LOG_LEVEL_ERROR'
});
return false;
}
get _pageEntries() {
const pagesPath = path.resolve(this.options.baseDir, './pages')
const pages = glob.sync('**/*.*', {
cwd: pagesPath
})
return pages as string[]
}
function generateEntry(server) {
const entry = glob.sync(`${PROJECT_ROOT}/src/assets/*.js`);
if (entry.length) {
const obj = {};
const file = entry[0];
const objProp = basename(file, '.js');
obj[objProp] = [file.replace(SOURCE_DIRECTORY, '.')];
if (Array.isArray(server)) {
server.reverse().forEach(item => obj[objProp].unshift(item));
}
return obj;
}
return null;
}