Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
// Before Webpack 4 - fileDepenencies was an array
compilation.fileDependencies.push(filename)
}
compilation.assets[filename] = {
source: () => html,
size: () => html.length
}
// console.log(html)
// 生产环境:写入文件
if (process.env.WEBPACK_BUILD_ENV === 'prod') {
const pathname = path.resolve(getDistPath(), 'public/', filename)
await fs.ensureFile(pathname)
await fs.writeFile(
pathname,
html,
'utf-8'
)
}
callback()
})
let localKeyPair: KeyPair
// 1. check if identity exists
const userPath = app.getPath('userData')
const keyPath = path.join(userPath, `${KEYNAME}.pub`)
const skeyPath = path.join(userPath, KEYNAME)
const exists = await fs.pathExists(keyPath)
// 2. create keypair
if (!exists) {
// 3. save keypair on disk
localKeyPair = keyPair()
try {
await fs.writeFile(keyPath, localKeyPair.publicKey)
await fs.writeFile(skeyPath, localKeyPair.secretKey)
} catch (e) {}
} else {
try {
localKeyPair = {
publicKey: await fs.readFile(keyPath),
secretKey: await fs.readFile(skeyPath)
}
} catch (e) {
localKeyPair = keyPair()
}
}
// convert old sodium-native keys to use new length compatible with libsodium-wrappers
if (localKeyPair.secretKey.length > sodium.crypto_box_PUBLICKEYBYTES) {
localKeyPair.secretKey = localKeyPair.secretKey.slice(0, sodium.crypto_box_PUBLICKEYBYTES)
fs.open(file, 'w', err => {
if (err) {
throw err;
}
fs.writeFile(file, json, er => {
if (er) {
return console.error(er);
}
console.log(`Created File ${colors.green(file)}`);
return file;
});
});
});
const truffleConfigPath = TruffleConfiguration.getTruffleConfigUri();
const truffleConfig = new TruffleConfiguration.TruffleConfig(truffleConfigPath);
const configuration = truffleConfig.getConfiguration();
const migrationFilePath = configuration.migrations_directory;
const filePath = path.join(
getWorkspaceRoot()!,
migrationFilePath,
migrationFilename,
);
Output.outputLine(
Constants.outputChannel.azureBlockchain,
`New migration for OpenZeppelin contracts was stored to file ${migrationFilename}`,
);
return fs.writeFile(filePath, content, { encoding: 'utf8' });
}
function(cb) {
fs.writeFile(webadminPath, ini.stringify(webadminConfig), function(error) {
if(error) {
log.error("An error occured trying to update the " + settings.webadmin + " file for " + config.name, error);
return;
} else {
log.verbose("Updated webadmin.ini file for " + config.name);
log.verbose("Completed plugin preflight for " + config.name);
callback();
}
});
}
]);
.then(png => fs.writeFile(outputFile, png).then(() => png)),
)
async function writeMock(mock, outputFolder, depth) {
let content = mock.data;
if (content === null) {
content = '';
} else if (typeof content === 'function') {
content = `module.exports = ${content.toString()};`;
} else if (typeof content === 'object' && !(content instanceof Buffer)) {
content = JSON.stringify(content, null, 2);
}
const outputFile = path.join(outputFolder, buildFile(mock, depth));
await fs.mkdirp(path.dirname(outputFile));
await fs.writeFile(outputFile, content);
}
const createFile = async (filePath, content) => {
if (await fs.exists(filePath)) {
await fs.appendFile(filePath, `\n\n${content}`)
} else {
await fs.ensureFile(filePath)
await fs.writeFile(filePath, content)
}
}
.replace(/VALUE "ProductVersion", .*/, 'VALUE "ProductVersion", "' + config.app.version + '"')
.replace(/VALUE "OriginalFilename", ".*"/, 'VALUE "OriginalFilename", "' + config.app.name + '.exe"')
.replace(/VALUE "InternalName", ".*"/, 'VALUE "InternalName", "' + config.app.name + '"');
if (config.icon) {
custom = custom.replace(/1 ICON .*/, '1 ICON ' + config.icon);
}
var patch = dmp.patch_make(data, custom);
if (patch.length === 0) {
debug('dont need to patch for icon');
return fn(null, config);
}
debug('icon patch', patch.toString());
debug('writing patched rc');
fs.writeFile(rc, dmp.patch_apply(patch, data)[0], function(_err) {
if (_err) {
return fn(_err);
}
debug('patch applied!');
return fn(null, config);
});
});
}