How to use the @expo/json-file.writeAsync function in @expo/json-file

To help you get started, we’ve selected a few @expo/json-file 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 expo / expo-cli / packages / xdl / src / project / Convert.js View on Github external
if (unsupportedPackages[dep]) {
      delete packageJson.dependencies[dep];
      unsupportedPackagesUsed.push(dep);
    }
  });

  // TODO: we don't actually support index.android.js and index.ios.js right now!
  if (
    projectEntryPoint !== 'index.*.js' &&
    projectEntryPoint !== 'index.js' &&
    projectEntryPoint !== 'index.ios.js' &&
    projectEntryPoint !== 'index.android.js'
  ) {
    packageJson.main = projectEntryPoint;
  }
  await JsonFile.writeAsync(packageJsonTargetPath, packageJson);
  console.log('Updated package.json');

  // TODO: Add import Expo from 'expo'; at the top of main file
  // Copy babelrc
  await JsonFile.writeAsync(babelRcTargetPath, babelRcTemplate);
  console.log('Updated .babelrc');

  // Save next steps to a file, display, exit
  await installAndInstructAsync(projectDir, unsupportedPackagesUsed);
});
github expo / expo-cli / packages / xdl / src / project / Convert.js View on Github external
// TODO: we don't actually support index.android.js and index.ios.js right now!
  if (
    projectEntryPoint !== 'index.*.js' &&
    projectEntryPoint !== 'index.js' &&
    projectEntryPoint !== 'index.ios.js' &&
    projectEntryPoint !== 'index.android.js'
  ) {
    packageJson.main = projectEntryPoint;
  }
  await JsonFile.writeAsync(packageJsonTargetPath, packageJson);
  console.log('Updated package.json');

  // TODO: Add import Expo from 'expo'; at the top of main file
  // Copy babelrc
  await JsonFile.writeAsync(babelRcTargetPath, babelRcTemplate);
  console.log('Updated .babelrc');

  // Save next steps to a file, display, exit
  await installAndInstructAsync(projectDir, unsupportedPackagesUsed);
});
github expo / expo-cli / packages / xdl / src / project / Convert.js View on Github external
{ projectName, projectDescription, projectEntryPoint }: params
) {
  let projectSlug = slug(projectName.toLowerCase());

  let expJsonTargetPath = path.join(projectDir, '/exp.json');
  let babelRcTargetPath = path.join(projectDir, '/.babelrc');

  let packageJsonSourcePath = path.join(projectDir, '/package.json');
  let packageJsonTargetPath = path.join(projectDir, '/package.json');

  // Add values to exp.json, save to given path
  let expJson = { ...expJsonTemplate };
  expJson.name = projectName;
  expJson.description = projectDescription || 'No description';
  expJson.slug = projectSlug;
  await JsonFile.writeAsync(expJsonTargetPath, expJson);
  console.log('Wrote exp.json');

  // Add entry point and dependencies to package.json
  let unsupportedPackagesUsed = [];
  let packageJson = await JsonFile.readAsync(packageJsonSourcePath);

  packageJson.dependencies = { ...packageJson.dependencies, ...dependencies };

  // Remove
  Object.keys(packageJson.dependencies).forEach(dep => {
    if (unsupportedPackages[dep]) {
      delete packageJson.dependencies[dep];
      unsupportedPackagesUsed.push(dep);
    }
  });
github expo / expo-cli / packages / config / src / Config.ts View on Github external
export async function writeConfigJsonAsync(
  projectRoot: string,
  options: Object
): Promise {
  const { configPath } = findConfigFile(projectRoot);
  let { exp, pkg, rootConfig } = await readConfigJsonAsync(projectRoot);
  exp = { ...exp, ...options };
  rootConfig = { ...rootConfig, expo: exp };

  await JsonFile.writeAsync(configPath, rootConfig, { json5: false });

  return {
    exp,
    pkg,
    rootConfig,
  };
}
github expo / expo-cli / dev / xdl / src / project / ProjectUtils.js View on Github external
if (!pkg) {
    throw new Error(`Couldn't read package.json`);
  }

  exp = {
    ...exp,
    ...options,
  };

  if (configNamespace) {
    config[configNamespace] = exp;
  } else {
    config = exp;
  }

  await JsonFile.writeAsync(configPath, config, { json5: false });

  return {
    exp,
    pkg,
    rootConfig,
  };
}

@expo/json-file

A module for reading, writing, and manipulating JSON files

MIT
Latest version published 27 days ago

Package Health Score

92 / 100
Full package analysis