How to use cp-file - 10 common examples

To help you get started, we’ve selected a few cp-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 webtorrent / webtorrent-desktop / test / setup.js View on Github external
function copy (pathFrom, pathTo) {
  try {
    cpFile.sync(pathFrom, pathTo)
  } catch (err) {
    // Windows lets us create files and folders under C:\Windows\Temp,
    // but when you try to `copySync` into one of those folders, you get EPERM
    // Ignore for now...
    if (process.platform !== 'win32' || err.code !== 'EPERM') throw err
    console.log('ignoring windows copy EPERM error', err)
  }
}
github willyb321 / media_mate / tests / setup.js View on Github external
function copy(pathFrom, pathTo) {
	try {
		cpFile.sync(pathFrom, pathTo);
	} catch (err) {
		// Windows lets us create files and folders under C:\Windows\Temp,
		// but when you try to `copySync` into one of those folders, you get EPERM
		// Ignore for now...
		if (process.platform !== 'win32' || err.code !== 'EPERM') {
			throw err;
		}
		console.log('ignoring windows copy EPERM error', err);
	}
}
github AdguardTeam / AdguardAssistant / metadata.plugin.js View on Github external
function createMetadata(compilation, callback, options) {
    const {
        filename,
        metadataTemplate = DEFAULT_METADATA_TEMPLATE,
        localesDir = DEFAULT_LOCALES_DIR,
        postfix = DEFAULT_POSTFIX,
        fields = {},
    } = options;

    // Calculate result metadata file path
    const metadataOutputPath = path.join(compilation.outputOptions.path, filename);

    // Copy template file to output directory
    copyfile.sync(metadataTemplate, metadataOutputPath);

    // Separate fields which have multiple translations and simple fields
    const multipleFields = {};
    const singleFields = {};
    Object.entries(fields).forEach(([key, value]) => {
        if (typeof value === 'object' && value !== null) {
            multipleFields[key] = value;
        } else {
            singleFields[key] = value;
        }
    });

    // Replace simple fields
    replaceWithMultipleSource(singleFields, metadataOutputPath);

    // Get all locales paths
github geut / chan / test / commands / helpers / create-fixture.js View on Github external
export default function createFixture(tmp, commands, fixtureName, cp = true) {
    const pathname = Array.isArray(commands) ? fixtureName : path.join(commands.name, fixtureName);
    const fixture = tmp.create(pathname);
    if (cp) {
        cpFile.sync(path.normalize(`fixtures/${pathname}/CHANGELOG.md`), path.join(fixture, 'CHANGELOG.md'));
    }
    return fixture;
}
github fiatjaf / sitio / index.js View on Github external
staticFiles.map(filepath => {
        console.log(`# copyStatic(${filepath})`)
        copy.sync(
          path.join(process.cwd(), filepath),
          path.join(targetdir, filepath)
        )
      })
    )
github webextensions / live-css-editor / zip-extension.js View on Github external
output.on('close', function() {
    try {
        del.sync(['extension/manifest.json']);
        cpFile.sync('extension/manifest-chrome.json', 'extension/manifest.json', {overwrite: false});

        console.log(chalk.green('The extension has been zipped as: ' + zipFileName + ' (' + archive.pointer() + ' bytes)'));
    } catch (e) {
        warnUserToCheckManifestFile(e);
    }
});
github VladimirIvanin / insales-uploader / lib / file-system / watch.js View on Github external
fs.readFile(file1,  (err1, data1) => {
          if (err1) {
            console.log(`Невозможно прочитать файл ${file1}`)
            return;
          }else{
            let difa = jsdiff.diffChars(data2.toString(encode), data1.toString(encode));
            let difSize = _.size(difa);
            if (difSize > 1) {
              if (debugMode) {
                console.log(`${file1} синхронизирован с ${file2}\n`);
              }
              cpFile.sync(file1, file2);
            }else{
              if (debugMode) {
                console.log(`Нет причин для синхронизации`)
                console.log(`${file1} идентичен ${file2}\n`);
              }
            }
          }
        });
      }else{
github docsifyjs / docsify-cli / lib / commands / init.js View on Github external
const vendor =
      exists(cwd('node_modules/docsify')) || pwd('../node_modules/docsify')

    cp(resolve(vendor, 'lib/docsify.min.js'), target('vendor/docsify.js'))
    cp(
      resolve(vendor, `lib/themes/${theme}.css`),
      target(`vendor/themes/${theme}.css`)
    )
  }

  const filename = 'index.html'

  cp(readme, target('README.md'))
  cp(main, target(filename))
  cp(pwd('template/.nojekyll'), target('.nojekyll'))

  replace(target(filename), 'vue.css', `${theme}.css`)

  if (pkg.name) {
    replace(
      target(filename),
      'Document',
      pkg.name + (pkg.description ? ' - ' + pkg.description : '')
    )
    replace(target(filename), 'name: \'\',', `name: '${pkg.name}',`)
  }

  if (pkg.description) {
    replace(target(filename), 'Description', pkg.description)
  }
github splunk / splunk-sdk-javascript / node_modules / nyc / index.js View on Github external
            .forEach(src => cpFile.sync(src, path.join(output, path.relative(input, src))))
        }
github docsifyjs / docsify-cli / lib / commands / init.js View on Github external
main = pwd('template/index.local.html')

    const vendor =
      exists(cwd('node_modules/docsify')) || pwd('../node_modules/docsify')

    cp(resolve(vendor, 'lib/docsify.min.js'), target('vendor/docsify.js'))
    cp(
      resolve(vendor, `lib/themes/${theme}.css`),
      target(`vendor/themes/${theme}.css`)
    )
  }

  const filename = 'index.html'

  cp(readme, target('README.md'))
  cp(main, target(filename))
  cp(pwd('template/.nojekyll'), target('.nojekyll'))

  replace(target(filename), 'vue.css', `${theme}.css`)

  if (pkg.name) {
    replace(
      target(filename),
      'Document',
      pkg.name + (pkg.description ? ' - ' + pkg.description : '')
    )
    replace(target(filename), 'name: \'\',', `name: '${pkg.name}',`)
  }

  if (pkg.description) {
    replace(target(filename), 'Description', pkg.description)
  }

cp-file

Copy a file

MIT
Latest version published 1 year ago

Package Health Score

61 / 100
Full package analysis

Popular cp-file functions