Example #1
0
const setCleanTestCwd = () => {
  const random = crypto.randomBytes(16).toString("hex");
  const path = `${os.tmpdir()}/fs-jetpack-test-${random}`;
  fse.mkdirSync(path);
  createdDirectories.push(path);
  process.chdir(path);
};
Example #2
0
walk.dirsSync(dataDirectory, function(dir: string, file: string, stat: any) {
	// Combine them together into the directories.
	var distDir = dir.replace(dataDirectory, distDirectory);
	var distDataDir = path.join(distDir, file);

	// Create the directory if it doesn't exist.
	if (!fs.existsSync(distDataDir)) {
		fs.mkdirSync(distDataDir);
	}
});
Example #3
0
 public generate() {
     this.cloneTemplate();
     const dir = this.config.name;
     const templateRepo = PlatformConfig.getRepository();
     const templateProjectName = GitGen.getRepoName(templateRepo.client);
     const replacePattern = { [templateProjectName]: dir };
     copySync(`${dir}/resources/gitignore/variantConfig.ts`, `${dir}/src/config/variantConfig.ts`);
     // for installing plugins this folder must exist
     mkdirSync(`${dir}/vesta/cordova/www`);
     findInFileAndReplace(`${dir}/vesta/cordova/config.xml`, replacePattern);
 }
Example #4
0
 nodes.forEach((node, index) => {
   tmpPath = path.join(tmpPath, node);
   if (fs.existsSync(tmpPath)) {
     return;
   }
   if (index === nodes.length - 1) {
     fs.writeFileSync(tmpPath, '');
   } else {
     fs.mkdirSync(tmpPath);
   }
 });
Example #5
0
 it('ng generate module child should work in sub-dir', function () {
   fs.mkdirSync(path.join(testPath, './sub-dir'));
   return new Promise(resolve => {
     process.chdir(path.join(testPath, './sub-dir'));
     return resolve();
   }).then(() =>
     ng(['generate', 'module', 'child']).then(() => {
       expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child.module.ts'))).to.equal(true);
       expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child.module.spec.ts'))).to.equal(false);
     })
   );
 });
 it('ng generate module child should work in sub-dir with routing file when passed --routing flag', (done) => {
   fs.mkdirSync(path.join(testPath, './sub-dir'));
   return new Promise(resolve => {
     process.chdir(path.join(testPath, './sub-dir'));
     return resolve();
   })
   .then(() => ng(['generate', 'module', 'child', '--routing']))
   .then(() => {
     expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child.module.ts'))).toBe(true);
     expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child-routing.module.ts'))).toBe(true);
     expect(fs.pathExistsSync(path.join(testPath, 'sub-dir/child', 'child.module.spec.ts'))).toBe(false);
   })
   .then(done, done.fail);
 });
export function createTemporaryDir(projectPath: string): string {
  let temporaryDir = path.join(projectPath, Constants.tempPath);
  let counter = Constants.defaultCounter;
  while (counter--) {
    const result = fs.pathExistsSync(temporaryDir);

    if (result) {
      temporaryDir = temporaryDir.concat(Math.floor(Math.random() * 10).toString());
    } else {
      fs.mkdirSync(temporaryDir);
      break;
    }
  }

  return temporaryDir;
}
Example #8
0
        .map((fileName) => {
          const source = path.join(packagesRoot, fileName);
          const dest = path.join(dist, fileName);

          if (fs.statSync(source).isDirectory()) {
            try {
              fs.mkdirSync(dest);
            } catch (err) {
              if (err.code != 'EEXIST') {
                throw err;
              }
            }
          } else {
            return copy(source, dest);
          }
        })
Example #9
0
export default function() {
  const root = process.cwd();
  const modulePath = join(root, 'src', 'app', 'app.module.ts');

  fs.mkdirSync('./src/app/sub-dir');

  return ng('generate', 'service', 'test-service', '--module', 'app.module.ts')
    .then(() => expectFileToMatch(modulePath,
      /import { TestServiceService } from '.\/test-service.service'/))

    .then(() => process.chdir(join(root, 'src', 'app')))
    .then(() => ng('generate', 'service', 'test-service2', '--module', 'app.module.ts'))
    .then(() => expectFileToMatch(modulePath,
      /import { TestService2Service } from '.\/test-service2.service'/))

    // Try to run the unit tests.
    .then(() => ng('build'));
}
Example #10
0
export default function() {
  const root = process.cwd();
  const modulePath = join(root, 'src', 'app', 'app.module.ts');

  fs.mkdirSync('./src/app/sub-dir');

  return ng('generate', 'guard', 'test-guard', '--module', 'app.module.ts')
    .then(() => expectFileToMatch(modulePath,
      /import { TestGuardGuard } from '.\/test-guard.guard'/))
    .then(() => expectFileToMatch(modulePath,
      /providers:\s*\[TestGuardGuard\]/m))

    .then(() => process.chdir(join(root, 'src', 'app')))
    .then(() => ng('generate', 'guard', 'test-guard2', '--module', 'app.module.ts'))
    .then(() => expectFileToMatch(modulePath,
      /import { TestGuard2Guard } from '.\/test-guard2.guard'/))

    .then(() => ng('build'));
}