How to use the @salesforce/core.fs.mkdirp function in @salesforce/core

To help you get started, we’ve selected a few @salesforce/core 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 eltoroit / ETCopyData / src / @ELTOROIT / Settings.ts View on Github external
return new Promise((resolve, reject) => {
			// Make folder
			const overrideFolder = overrideSettings.configfolder;
			if (!readFolder) {
				readFolder = "ETCopyData";
			}
			this.rootFolderRaw = readFolder;
			this.rootFolderFull = this.rootFolderRaw;

			if (overrideFolder) {
				if (readFolder.indexOf(overrideFolder) !== 0) {
					this.rootFolderFull = overrideFolder + "/" + readFolder;
				}
			}

			fs.mkdirp(this.rootFolderFull)
				.then(() => {
					let path: string = "";
					path = this.rootFolderFull;

					// VERBOSE: Create sub-folders based on time so files do not override
					// path += `/${Util.getWallTime(true)}`;

					fs.mkdirp(path)
						.then(() => {
							this.rootFolderFull = path;
							resolve(this.rootFolderFull);
						});
				});
		});
	}
github eltoroit / ETCopyData / src / @ELTOROIT / Settings.ts View on Github external
.then(() => {
					let path: string = "";
					path = this.rootFolderFull;

					// VERBOSE: Create sub-folders based on time so files do not override
					// path += `/${Util.getWallTime(true)}`;

					fs.mkdirp(path)
						.then(() => {
							this.rootFolderFull = path;
							resolve(this.rootFolderFull);
						});
				});
		});
github ChuckJonas / sfdx-git-packager / src / commands / git / package.ts View on Github external
}
          if (purge) {
            this.ux.log(`Removing all files inside of ${outDir}`);
            try {
              await purgeFolder(outDir);
            } catch (e) {
              this.ux.error(e);
              this.exit(1);
              return;
            }

          }
        }
      } catch (e) { }

      await fs.mkdirp(outDir);

      if (hasChanges) {
        await spawnPromise('sfdx', ['force:source:convert', '-d', outDir], { shell: true, cwd: tmpProject });
      }
      if (hasDeletions) {
        await fsPromise.copyFile(`${tempDeleteProjConverted}/package.xml`, `${outDir}/destructiveChangesPost.xml`);
        if (!hasChanges) {
          await fsPromise.writeFile(
            `${outDir}/package.xml`,
            ''
          );
        }
      }
    } catch (e) {
      this.ux.error(e);
      this.exit(1);
github ChuckJonas / sfdx-git-packager / src / commands / git / package.ts View on Github external
private async mkTempDir() {
    const tempDir = await new Promise((resolve, reject) => {
      tmp.dir((err, path) => {
        if (err) {
          reject(err);
        }
        resolve(path);
      });
    });
    await fs.mkdirp(tempDir);
    return tempDir;
  }
github ChuckJonas / sfdx-git-packager / src / commands / git / package.ts View on Github external
for (const path of changed) {
      const metadataPaths = await resolveMetadata(path, targetRef);

      if (!metadataPaths) {
        this.ux.warn(`Could not resolve metadata for ${path}`);
        continue;
      }

      for (let mdPath of metadataPaths) {
        if (isAbsolute(mdPath)) {
          mdPath = relative(this.projectPath, mdPath);
        }

        const newPath = join(tempDir, mdPath);
        await fs.mkdirp(dirname(newPath));
        await copyFileFromRef(mdPath, targetRef, newPath);
      }
    }

    return tempDir;
  }
github stomita / sfdx-migration-automatic / src / commands / automig / dump.ts View on Github external
let fetchedCountPerObject = {};
    am.on('dumpProgress', status => {
      fetchedCount = status.fetchedCount;
      fetchedCountPerObject = status.fetchedCountPerObject;
      const perObjectCount = Object.keys(fetchedCountPerObject).map(object => `${object}: ${fetchedCountPerObject[object]}`).join(', ');
      const message = `fetched count: ${fetchedCount}, ${perObjectCount}`;
      this.ux.setSpinnerStatus(message);
    });
    this.ux.startSpinner('dumping records');
    const csvs = await am.dumpAsCSVData(config.targets);
    this.ux.stopSpinner();
    this.ux.log(`fetched count: ${fetchedCount}`);
    try {
      await fs.stat(config.outputDir);
    } catch (e) {
      await fs.mkdirp(config.outputDir);
    }
    const results = await Promise.all(
      config.targets.map(async ({ object }, i) => {
        const csv = csvs[i];
        const count = fetchedCountPerObject[object] || 0;
        const filename = `${object}.csv`;
        const filepath = path.join(config.outputDir, filename);
        const bom = this.flags.excludebom ? '' : '\ufeff';
        await writeFile(filepath, bom + csv, 'utf8');
        return { filepath, count };
      })
    );
    this.ux.log();
    this.ux.table(
      results,
      {