Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function makeProperTestDir(dirname: string) {
const startingDir = path.join(baseDir, dirname);
const tempDir = path.join(baseDir, 'temp');
if (await exists(tempDir)) {
await new Promise((resolve, reject) => {
rimraf(tempDir, (err) => err ? reject(err) : resolve());
});
}
fs.mkdirSync(tempDir);
// copy dir
const pathToTestDir = await copyDir(startingDir, tempDir);
const bowerDir = bowerConfig.read(pathToTestDir).directory;
fs.mkdirSync(path.join(pathToTestDir, 'node_modules'));
fs.mkdirSync(
path.join(pathToTestDir, 'node_modules', 'web-component-tester'));
// set up symlinks into component dirs for browser.js, data/, and wct's
// dependencies (like mocha, sinon, etc)
const componentsDirs = new Set([bowerDir]);
for (const baseFile of fs.readdirSync(startingDir)) {
if (new RegExp(`${bowerDir}(-|$)`).test(baseFile)) {
componentsDirs.add(baseFile);
}
}
for (const baseComponentsDir of componentsDirs) {
const componentsDir = path.join(pathToTestDir, baseComponentsDir);
var tty = require('tty');
var mout = require('mout');
var config = require('bower-config').read();
var cli = require('./util/cli');
// Delete the json attribute because it is no longer supported
// and conflicts with --json
delete config.json;
// If interactive is auto (null), guess its value
if (config.interactive == null) {
config.interactive = (
process.bin === 'bower' &&
tty.isatty(1) &&
!process.env.CI
);
}
// If `analytics` hasn't been explicitly set, we disable
var tty = require('tty');
var mout = require('mout');
var config = require('bower-config').read();
var cli = require('./util/cli');
// Delete the json attribute because it is no longer supported
// and conflicts with --json
delete config.json;
// If interactive is auto (null), guess its value
if (config.interactive == null) {
config.interactive = process.bin === 'bower' && tty.isatty(1);
}
// Merge common CLI options into the config
mout.object.mixIn(config, cli.readOptions({
force: { type: Boolean, shorthand: 'f' },
offline: { type: Boolean, shorthand: 'o' },
verbose: { type: Boolean, shorthand: 'V' },
// Time how long tasks take. Can help when optimizing build times
require('time-grunt')(grunt);
// Ensure copyright banners
require('./copyright')(grunt);
var saveLicense = require('uglify-save-license');
// Define the configuration for all the tasks
grunt.initConfig({
// Project settings
yeoman: {
// configurable paths
app: require('./bower.json').appPath || 'app',
bower: require('bower-config').read('').directory || 'app/bower_components',
dist: 'dist',
target: 'target',
test: 'test'
},
stage: {
name: process.env.STAGE || 'development'
},
dmpProject: {
backendDir: process.env.DMP_HOME || '../../data-management-platform',
name: 'd:swarm',
versions: {
web: {
revision: 'HEAD',
date: 'latest'
function readCachedConfig(cwd) {
if (cachedConfigs[cwd]) {
return cachedConfigs[cwd];
}
var config = cachedConfigs[cwd] = bowerConfig.read(cwd);
var configstore = new Configstore('bower-github').all;
object.mixIn(config, configstore);
// Delete the json attribute because it is no longer supported
// and conflicts with --json
delete config.json;
// If interactive is auto (null), guess its value
if (config.interactive == null) {
config.interactive = (
process.bin === 'bower' &&
tty.isatty(1) &&
!process.env.CI
);
}
function bowerTrees () {
var bowerDir = require('bower-config').read().directory // note: this relies on cwd
if (bowerDir == null) throw new Error('Bower did not return a directory')
var entries = fs.readdirSync(bowerDir)
var directories = entries.filter(function (f) {
return fs.statSync(path.join(bowerDir, f)).isDirectory()
})
var files = entries.filter(function (f) {
var stat = fs.statSync(path.join(bowerDir, f))
return stat.isFile() || stat.isSymbolicLink()
})
var trees = []
for (var i = 0; i < directories.length; i++) {
trees = trees.concat(Tree._fromDirectory(path.join(bowerDir, directories[i])))
}
// Pick up files as well; this is for compatibility with EAK's vendor/loader.js
for (i = 0; i < files.length; i++) {
trees.push(new Tree(bowerDir).map('/' + files[i], '/' + files[i]))
function findBowerDirectory(cwd) {
var directory = path.join(cwd, (bowerConfig.read(cwd).directory || 'bower_components'));
if (!fs.existsSync(directory)) {
console.log(chalk.red.bold('Cannot find where you keep your Bower packages.'));
process.exit();
}
return directory;
}
var promises = Object.keys(packages).map(function (depName) {
var dep = packages[depName];
var depPath = dep.canonicalDir || path.join(rootComponentsDir, dep.name);
var conf = Config.read(depPath);
var componentsDir = path.join(conf.cwd, conf.directory);
return readJson(depPath)
.spread(function (json, deprecated, assumed) {
if (json.dependencies) {
return Q.all(Object.keys(json.dependencies || {}).map(function (d) {
var dst = path.join(componentsDir, d);
var src = path.join(rootComponentsDir, d);
return Q.nfcall(fs.stat, dst)
.fail(function () {
logger.info('dep-link', d, {
name: json.name + '#' + d
});
return createLink(src, dst, {relative: true});
});
var BowerClient = function () {
this._client = bower;
this._registryClient = new RegistryClient(Config.read(process.cwd()));
};