当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs.symlinkSync函数代码示例

本文整理汇总了TypeScript中fs.symlinkSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript symlinkSync函数的具体用法?TypeScript symlinkSync怎么用?TypeScript symlinkSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了symlinkSync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: setupBazelTo

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;
  }
}
开发者ID:zackarychapple,项目名称:angular,代码行数:32,代码来源:test_support.ts

示例2: setupBazelTo

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);
  }
}
开发者ID:hulkike,项目名称:angular,代码行数:31,代码来源:test_support.ts

示例3: beforeEach

 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'));
 });
开发者ID:DanielKucal,项目名称:angular,代码行数:33,代码来源:ngc_spec.ts

示例4: beforeEach

 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'));
 });
开发者ID:rjamet,项目名称:angular,代码行数:26,代码来源:main_spec.ts

示例5: getAngularPackagesFromRunfiles

  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'));
    }
  });
开发者ID:zackarychapple,项目名称:angular,代码行数:9,代码来源:test_support.ts

示例6: makeProperTestDir

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;
}
开发者ID:Polymer,项目名称:web-component-tester,代码行数:57,代码来源:setup_test_dir.ts

示例7: it

		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);
		});
开发者ID:AhmadAlyTanany,项目名称:code-server,代码行数:7,代码来源:fs.test.ts

示例8: dir_symlink

function dir_symlink(source: string, target: string) {
    try {
        __fs.symlinkSync(source, target, 'junction');
    } catch (error) {
        logger.error('symlink: bold<%s>', error);
    }
}
开发者ID:atmajs,项目名称:atma-io,代码行数:7,代码来源:fs_dir.ts

示例9: useRubyVersion

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);
    }
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:28,代码来源:userubyversion.ts

示例10: function

        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();
        }
开发者ID:i-e-b,项目名称:gulp-npmworkspace,代码行数:28,代码来源:PostInstallTypings.ts


注:本文中的fs.symlinkSync函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。