How to use replace - 5 common examples

To help you get started, we’ve selected a few replace 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 aragon / aragon-cli / packages / create-aragon-app / src / lib / prepare-template.js View on Github external
]

  defaultRegistries.forEach(registry => {
    replace({
      regex: registry,
      replacement: appName,
      paths: [projectPath],
      recursive: true,
      silent: true,
    })
  })

  /**
   * Replace the placeholder name with the actual name
   */
  replace({
    regex: 'placeholder-app-name',
    replacement: basename,
    paths: [projectPath],
    recursive: true,
    silent: true,
  })

  return Promise.all([fs.remove(gitFolderPath), fs.remove(licensePath)])
}
github Jacky-fe / react-isomorphic-skeleton / tools / copy.js View on Github external
} else {
          resolve()
        }
      })
    });
  };

  await Promise.all([
    ncp('src/static', 'dist/static'),
    ncp('src/views', 'dist/views'),
    ncp('package.json', 'dist/package.json'),
    ncp('config.js', 'dist/config.js'),
    ncp('config.js', 'src/config.js'),
  ]);

  replace({
    regex: '"start".*',
    replacement: '"start": "node server.js",',
    paths: ['dist/package.json'],
    recursive: false,
    silent: false,
  });

  if (watch) {
    const viewsWatcher = await new Promise((resolve, reject) => {
      gaze('src/views/**/*.*', (err, val) => err ? reject(err) : resolve(val));
    });
    viewsWatcher.on('changed', async (file) => {
      const relPath = file.substr(path.join(__dirname, '../src/views/').length);
      await ncp(`src/views/${relPath}`, `dist/views/${relPath}`);
    });
    const configWatcher = await new Promise((resolve, reject) => {
github insoftpub / storefront / tools / copy.js View on Github external
async function copy({ watch } = {}) {
    const ncp = Promise.promisify(require('ncp'));

    await Promise.all([
        ncp('servers/static/public', 'build/public'),
        ncp('src/images', 'build/public/images'),
        ncp('src/content', 'build/content'),
        ncp('package.json', 'build/package.json'),
        ncp('servers/api/email', 'build/email')
    ]);

    replace({
        regex: '"start".*',
        replacement: '"start": "node static-server.js"',
        paths: ['build/package.json'],
        recursive: false,
        silent: false
    });

    if (watch) {
        const watcher = await new Promise((resolve, reject) => {
            gaze('src/content/**/*.*', (err, val) => err ? reject(err) : resolve(val));
        });

        watcher.on('changed', async(file) => {
            const relPath = file.substr(path.join(__dirname, '../src/content/').length);

            await ncp(`src/content/${relPath}`, `build/content/${relPath}`);
github aragon / aragon-cli / packages / aragon-cli / src / lib / init / prepare-template.js View on Github external
]

  defaultRegistries.forEach(registry => {
    replace({
      regex: registry,
      replacement: appName,
      paths: [dir],
      recursive: true,
      silent: true,
    })
  })

  /**
   * Replace the placeholder name with the actual name
   */
  replace({
    regex: 'placeholder-app-name',
    replacement: dir,
    paths: [dir],
    recursive: true,
    silent: true,
  })

  return Promise.all([fs.remove(gitFolderPath), fs.remove(licensePath)])
}
github cheshire137 / hue-steamer / tools / copy.js View on Github external
async function copy({ watch } = {}) {
  const ncp = Promise.promisify(require('ncp'));

  await Promise.all([
    ncp('src/public', 'build/public'),
    ncp('package.json', 'build/package.json'),
  ]);

  replace({
    regex: '"start".*',
    replacement: '"start": "node server.js"',
    paths: ['build/package.json'],
    recursive: false,
    silent: false,
  });
}

replace

Command line search and replace utility

MIT
Latest version published 2 years ago

Package Health Score

56 / 100
Full package analysis

Popular replace functions