How to use the @ionic/utils-fs.tmpfilepath function in @ionic/utils-fs

To help you get started, we’ve selected a few @ionic/utils-fs 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 ionic-team / ionic-cli / packages / ionic / src / commands / package / build.ts View on Github external
async downloadBuild(url: string, filename: string): Promise {
    const { req } = await createRequest('GET', url, this.env.config.getHTTPConfig());

    if (!filename) {
      req.on('response', res => {
        const contentDisposition = res.header['content-disposition'];
        filename = contentDisposition ? contentDisposition.split('=')[1] : 'output.bin';
      });
    }

    const tmpFile = tmpfilepath('ionic-package-build');
    const ws = fs.createWriteStream(tmpFile);
    await download(req, ws, {});
    fs.renameSync(tmpFile, filename);

    return filename;
  }
}
github ionic-team / ionic-cli / packages / ionic / src / commands / ssl / generate.ts View on Github external
[req]
default_bits       = ${bits}
distinguished_name = req_distinguished_name

[req_distinguished_name]
countryName                = ${countryName}
stateOrProvinceName        = ${stateOrProvinceName}
localityName               = ${localityName}
organizationName           = ${organizationName}
commonName                 = ${commonName}

[SAN]
subjectAltName=DNS:${commonName}
`.trim();

    const p = tmpfilepath('ionic-ssl');
    await writeFile(p, cnf, { encoding: 'utf8' });
    return p;
  }
}
github ionic-team / ionic-cli / packages / ionic / src / lib / integrations / cordova / resources.ts View on Github external
export async function transformResourceImage(env: IonicEnvironment, resource: ImageResource): Promise {
  const { req } = await createRequest('POST', TRANSFORM_URL, env.config.getHTTPConfig());
  const tmpDest = tmpfilepath(`ionic-cordova-resources-${resource.name}`);

  return new Promise(resolve => {
    let errorMarker = false;
    const result: ImageResourceTransformResult = { resource, tmpDest };

    debug('creating write stream for tmp file: %s', tmpDest);

    const tmpfp = fs.createWriteStream(tmpDest)
      .on('error', (err: Error) => {
        result.error = err;
      })
      .on('finish', () => {
        if (!errorMarker) {
          resolve(result);
        }
      });