How to use the shelljs.ls function in shelljs

To help you get started, we’ve selected a few shelljs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kitware / paraviewweb / tools / doc-generator / doc-generator-cli.js View on Github external
function processClass(bPath, className) {
  var files = shell.ls(path.join(bPath, className))
        .filter(function(f) {
          return shell.test('-f', path.join(bPath, className, f));
        }),
      apiIdx = files.indexOf('api.md'),
      newPath = path.join(process.env.PWD, 'documentation/www/source/api', className + '.md');

  if(apiIdx !== -1) {
    files.splice(apiIdx, 1);
    apiFound.push(className);
    console.log('  +', className);

    // Create MD file
    ('title: ' + className + '\n---\n').to(newPath);
    shell.cat(path.join(bPath, className, 'api.md')).toEnd(newPath);
  } else {
    console.log('  -', className);
github poetic / reacterminator / lib / generate / regenerate-custom-index.js View on Github external
function silentLs(folders) {
  const preSilentState = shell.config.silent;  // save old silent state
  shell.config.silent = true;

  const paths = shell.ls(folders);

  shell.config.silent = preSilentState; // restore old silent state

  return paths;
}
github fjc0k / vtils / packages / vtils / scripts / buildLib.ts View on Github external
// 切换至工作目录
  _.cd(wd)

  // 清空 lib 文件夹
  _.rm('-rf', 'lib')

  // 构建包
  _.exec('yarn bili')

  // 生成类型文件
  try {
    _.exec('api-extractor run')
  } catch (err) {}

  // 删除多余的文件
  _.ls('-d', 'lib/*').forEach(file => {
    if ((
      file.endsWith('.d.ts')
        || file.endsWith('.json')
        || fs.statSync(file).isDirectory()
    ) && (
      !file.endsWith('index.d.ts')
    )) {
      _.rm('-rf', file)
    }
  })

  // 替换 Object.assign 为自带的 assign
  _.ls('lib/*.js').forEach(builtFile => {
    _.sed(
      '-i',
      new RegExp(
github ionic-team / capacitor / packages / cli / dist / commands / open.js View on Github external
function open(files) {
    const platform = files.shift();
    console.log(files);
    const platformFolders = shelljs_1.ls(platform);
    const first = platformFolders[0];
    if (!first) {
        return 1;
    }
    const dest = path_1.join(platform, first);
    if (platform == 'ios') {
        common_1.log('ls');
        const proj = shelljs_1.ls(dest).filter(f => f.indexOf('.xcodeproj') >= 0)[0];
        if (!proj) {
            common_1.logError('open', 'Unable to find Xcode project');
            return 1;
        }
        const fullPath = path_1.join(dest, proj);
        common_1.log('open', fullPath);
        shelljs_1.exec(`open ${fullPath}`);
    }
github jhipster / generator-jhipster / generators / docker-compose / prompts.js View on Github external
function getAppFolders(input, composeApplicationType) {
    const files = shelljs.ls('-l', this.destinationPath(input));
    const appsFolders = [];

    files.forEach((file) => {
        if (file.isDirectory()) {
            if ((shelljs.test('-f', `${input + file.name}/.yo-rc.json`))
                && (shelljs.test('-f', `${input + file.name}/src/main/docker/app.yml`))) {
                try {
                    const fileData = this.fs.readJSON(`${input + file.name}/.yo-rc.json`);
                    if ((fileData['generator-jhipster'].baseName !== undefined)
                        && ((composeApplicationType === undefined)
                            || (composeApplicationType === fileData['generator-jhipster'].applicationType)
                            || ((composeApplicationType === 'microservice') && (fileData['generator-jhipster'].applicationType === 'gateway'))
                            || ((composeApplicationType === 'microservice') && (fileData['generator-jhipster'].applicationType === 'uaa')))) {
                        appsFolders.push(file.name.match(/([^/]*)\/*$/)[1]);
                    }
                } catch (err) {
github abeisgoat / firepit / firepit.js View on Github external
function uninstallLegacyFirepit() {
  const isLegacy = !shell.ls(path.join(homePath, ".cache", "firebase", "cli")).code;

  if (!isLegacy) return;
  debug("Legacy firepit detected, clearing it out...");
  debug(shell.rm("-rf", path.join(homePath, ".cache", "firebase")));
}
github Leeft / Star-Citizen-WebGL-Map / node_modules / grunt-contrib-jshint / node_modules / jshint / src / cli.js View on Github external
function collect(fp, files, ignores, ext) {
  if (ignores && isIgnored(fp, ignores)) {
    return;
  }

  if (!shjs.test("-e", fp)) {
    cli.error("Can't open " + fp);
    return;
  }

  if (shjs.test("-d", fp)) {
    shjs.ls(fp).forEach(function (item) {
      var itempath = path.join(fp, item);
      if (shjs.test("-d", itempath) || item.match(ext)) {
        collect(itempath, files, ignores, ext);
      }
    });

    return;
  }

  files.push(fp);
}
github rekit / rekit / packages / rekit-core / common / projectFiles.js View on Github external
function readDir(dir) {
  const prjRoot = paths.getProjectRoot();

  dir = dir || paths.map('src');

  const elementById = {};
  const elements = [];

  shell.ls(dir).forEach(file => {
    file = paths.join(dir, file);
    const rFile = file.replace(prjRoot, '');
    elements.push(rFile);
    if (shell.test('-d', file)) {
      const res = readDir(file);
      Object.assign(elementById, res.elementById);
      elementById[rFile] = {
        name: path.basename(file),
        type: 'folder',
        id: rFile,
        children: res.elements,
      };
    } else {
      elementById[rFile] = {
        name: path.basename(file),
        type: 'file',
github mozilla / apk-factory-service / node_modules / grunt-contrib-jshint / node_modules / jshint / src / cli / cli.js View on Github external
function collect(fp, files, ignores, ext) {
	if (ignores && isIgnored(fp, ignores)) {
		return;
	}

	if (!shjs.test("-e", fp)) {
		cli.error("Can't open " + fp);
		return;
	}

	if (shjs.test("-d", fp)) {
		shjs.ls(fp).forEach(function (item) {
			var itempath = path.join(fp, item);
			if (shjs.test("-d", itempath) || item.match(ext)) {
				collect(itempath, files, ignores, ext);
			}
		});

		return;
	}

	files.push(fp);
}
github wojtkowiak / meteor-desktop / lib / desktop.js View on Github external
gatherModuleConfigs() {
        const configs = [];

        if (!isEmptySync(this.$.env.paths.desktop.modules)) {
            shell.ls('-d', path.join(this.$.env.paths.desktop.modules, '*')).forEach(
                (module) => {
                    if (fs.lstatSync(module).isDirectory()) {
                        const moduleConfig = this.getModuleConfig(module);
                        moduleConfig.dirName = path.parse(module).name;
                        configs.push(moduleConfig);
                    }
                }
            );
        }
        return configs;
    }