Beispiel #1
0
export function setupBazelTo(tmpDirPath: string) {
  const nodeModulesPath = path.join(tmpDirPath, 'node_modules');
  const angularDirectory = path.join(nodeModulesPath, '@angular');

  fs.mkdirSync(nodeModulesPath);
  fs.mkdirSync(angularDirectory);

  getAngularPackagesFromRunfiles().forEach(({pkgPath, name}) => {
    fs.symlinkSync(pkgPath, path.join(angularDirectory, name), 'dir');

    // todo: check why we always need an index.d.ts
    if (!fs.existsSync(path.join(angularDirectory, name, 'index.d.ts'))) {
      fs.symlinkSync(
          path.join(pkgPath, `${name}.d.ts`), path.join(angularDirectory, name, 'index.d.ts'));
    }
  });

  // Link typescript
  const typeScriptSource = resolveNpmTreeArtifact('npm/node_modules/typescript');
  const typescriptDest = path.join(nodeModulesPath, 'typescript');
  fs.symlinkSync(typeScriptSource, typescriptDest, 'dir');

  // Link "rxjs" if it has been set up as a runfile. "rxjs" is linked optionally because
  // not all compiler-cli tests need "rxjs" set up.
  try {
    const rxjsSource = resolveNpmTreeArtifact('rxjs', 'index.js');
    const rxjsDest = path.join(nodeModulesPath, 'rxjs');
    fs.symlinkSync(rxjsSource, rxjsDest, 'dir');
  } catch (e) {
    if (e.code !== 'MODULE_NOT_FOUND') throw e;
  }
}
Beispiel #2
0
export function setupBazelTo(basePath: string) {
  const sources = process.env.TEST_SRCDIR;
  const packages = path.join(sources, 'angular/packages');
  const nodeModulesPath = path.join(basePath, 'node_modules');
  const angularDirectory = path.join(nodeModulesPath, '@angular');
  fs.mkdirSync(nodeModulesPath);

  // Link the built angular packages
  fs.mkdirSync(angularDirectory);
  const packageNames = fs.readdirSync(packages).filter(
      name => fs.statSync(path.join(packages, name)).isDirectory() &&
          fs.existsSync(path.join(packages, name, 'npm_package')));
  for (const pkg of packageNames) {
    fs.symlinkSync(path.join(packages, `${pkg}/npm_package`), path.join(angularDirectory, pkg));
  }

  // Link rxjs
  const rxjsSource = path.join(sources, 'rxjs');
  const rxjsDest = path.join(nodeModulesPath, 'rxjs');
  if (fs.existsSync(rxjsSource)) {
    fs.symlinkSync(rxjsSource, rxjsDest);
  }

  // Link typescript
  const typescriptSource =
      path.join(sources, 'angular/external/angular_deps/node_modules/typescript');
  const typescriptDest = path.join(nodeModulesPath, 'typescript');
  if (fs.existsSync(typescriptSource)) {
    fs.symlinkSync(typescriptSource, typescriptDest);
  }
}
Beispiel #3
0
 beforeEach(() => {
   errorSpy = jasmine.createSpy('consoleError');
   basePath = makeTempDir();
   write = (fileName: string, content: string) => {
     const dir = path.dirname(fileName);
     if (dir != '.') {
       const newDir = path.join(basePath, dir);
       if (!fs.existsSync(newDir)) fs.mkdirSync(newDir);
     }
     fs.writeFileSync(path.join(basePath, fileName), content, {encoding: 'utf-8'});
   };
   write('tsconfig-base.json', `{
     "compilerOptions": {
       "experimentalDecorators": true,
       "skipLibCheck": true,
       "types": [],
       "outDir": "built",
       "declaration": true,
       "module": "es2015",
       "moduleResolution": "node",
       "lib": ["es6", "dom"]
     }
   }`);
   outDir = path.resolve(basePath, 'built');
   const ngRootDir = getNgRootDir();
   const nodeModulesPath = path.resolve(basePath, 'node_modules');
   fs.mkdirSync(nodeModulesPath);
   fs.symlinkSync(
       path.resolve(ngRootDir, 'dist', 'all', '@angular'),
       path.resolve(nodeModulesPath, '@angular'));
   fs.symlinkSync(
       path.resolve(ngRootDir, 'node_modules', 'rxjs'), path.resolve(nodeModulesPath, 'rxjs'));
 });
Beispiel #4
0
 beforeEach(() => {
   basePath = makeTempDir();
   write = (fileName: string, content: string) => {
     fs.writeFileSync(path.join(basePath, fileName), content, {encoding: 'utf-8'});
   };
   write('tsconfig-base.json', `{
     "compilerOptions": {
       "experimentalDecorators": true,
       "types": [],
       "outDir": "built",
       "declaration": true,
       "module": "es2015",
       "moduleResolution": "node",
       "lib": ["es6", "dom"]
     }
   }`);
   outDir = path.resolve(basePath, 'built');
   const ngRootDir = getNgRootDir();
   const nodeModulesPath = path.resolve(basePath, 'node_modules');
   fs.mkdirSync(nodeModulesPath);
   fs.symlinkSync(
       path.resolve(ngRootDir, 'dist', 'all', '@angular'),
       path.resolve(nodeModulesPath, '@angular'));
   fs.symlinkSync(
       path.resolve(ngRootDir, 'node_modules', 'rxjs'), path.resolve(nodeModulesPath, 'rxjs'));
 });
Beispiel #5
0
  getAngularPackagesFromRunfiles().forEach(({pkgPath, name}) => {
    fs.symlinkSync(pkgPath, path.join(angularDirectory, name), 'dir');

    // todo: check why we always need an index.d.ts
    if (!fs.existsSync(path.join(angularDirectory, name, 'index.d.ts'))) {
      fs.symlinkSync(
          path.join(pkgPath, `${name}.d.ts`), path.join(angularDirectory, name, 'index.d.ts'));
    }
  });
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);
    if (!await exists(componentsDir)) {
      fs.mkdirSync(componentsDir);
    }
    // all of wct's bower deps should be present in the project under tests'
    // components dir
    const bowerDeps =
        fs.readdirSync(path.join(__dirname, '../../bower_components'));
    for (const baseFile of bowerDeps) {
      fs.symlinkSync(
          path.join('../../../../../../bower_components', baseFile),
          path.join(componentsDir, baseFile));
    }
    // Also set up a web-component-tester dir with symlinks into our own
    // client-side files.
    const wctDir = path.join(componentsDir, 'web-component-tester');
    fs.mkdirSync(wctDir);
    fs.symlinkSync(
        '../../../../../../../browser.js', path.join(wctDir, 'browser.js'),
        'file');
    fs.symlinkSync(
        '../../../../../../../package.json', path.join(wctDir, 'package.json'),
        'file');
    fs.symlinkSync(
        '../../../../../../../data', path.join(wctDir, 'data'), 'dir');
  }

  return pathToTestDir;
}
Beispiel #7
0
		it("should read real path of existing file", async () => {
			const source = await createTmpFile();
			const destination = tmpFile();
			nativeFs.symlinkSync(source, destination);
			await expect(util.promisify(fs.realpath)(destination))
				.resolves.toBe(source);
		});
Beispiel #8
0
function dir_symlink(source: string, target: string) {
    try {
        __fs.symlinkSync(source, target, 'junction');
    } catch (error) {
        logger.error('symlink: bold<%s>', error);
    }
}
Beispiel #9
0
export async function useRubyVersion(parameters: TaskParameters, platform: Platform): Promise<void> {
    const toolName: string = 'Ruby';
    const installDir: string | null = tool.findLocalTool(toolName, parameters.versionSpec);
    if (!installDir) {
        // Fail and list available versions
        throw new Error([
            task.loc('VersionNotFound', parameters.versionSpec),
            task.loc('ListAvailableVersions'),
            tool.findLocalToolVersions('Ruby')
        ].join(os.EOL));
    }

    const toolPath: string = path.join(installDir, 'bin');
    if (platform !== Platform.Windows) {
        // replace the default
        const dest: string = '/usr/bin/ruby';
        if (fs.existsSync(dest)) {
            task.debug('removing ' + dest);
            fs.unlinkSync(dest);
        }
        fs.symlinkSync(path.join(toolPath, 'ruby'), dest);
    }

    task.setVariable('rubyLocation', toolPath);
    if (parameters.addToPath) {
        tool.prependPath(toolPath);
    }
}
        action: function (packageDescriptor: PackageDescriptor, packagePath: string, callback: (error?: Error) => void): void {
            let packageTypingsFilePath = path.join(packagePath, "typings.json");
            let packageTypingsPath = path.join(packagePath, targetPath);

            if (!fs.existsSync(packageTypingsPath)) {
                fs.mkdirSync(packageTypingsPath);
            }
            else {
                rimraf.sync(packageTypingsPath + "/**/*");
            }

            Logger.verbose(`Linking typings for workspace package '${util.colors.cyan(packageDescriptor.name)}'`);

            let typingFilePaths = getTypingFileReferences(require(packageTypingsFilePath));

            for (let typingFilePathEntry in typingFilePaths) {
                let typingFilePath = path.resolve(packagePath, typingFilePaths[typingFilePathEntry]);
                let targetTypingFilePath = path.join(packageTypingsPath, typingFilePathEntry);

                fs.mkdirSync(targetTypingFilePath);

                fs.symlinkSync(typingFilePath, path.join(targetTypingFilePath, `${typingFilePathEntry}.d.ts`));

                Logger.verbose(`Linked typing '${util.colors.cyan(typingFilePathEntry)}' (-> '${util.colors.blue(typingFilePath)}')`);
            }

            callback();
        }