Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fileList.forEach(node => {
let { type, file } = node;
let hash = '';
let code = '';
if (/\[hash\]/.test(file)) {
if (file === destPath) {
// data.code will remove the last line of the source code(//# sourceMappingURL=xxx), so it's needed to add this
code = data.code + `//# sourceMappingURL=${basename(file)}.map`;
} else {
code = readFileSync(file).toString();
}
hash = hasha(code, { algorithm: 'md5' });
// remove the file without hash
unlinkSync(file);
file = file.replace('[hash]', hash)
writeFileSync(file, code);
}
const src = isURL(file) ? file : relative(firstDir, file);
if (type === 'js') {
let attrs = {src: src};
let mode = node.mode || defaultmode;
if (mode) attrs.type = mode;
attrs = Object.entries(([key, val]) => `${key}="${val}"`).join(' ');
const script = `\n`;
// node.inject will cover the inject
if (node.inject === 'head' || inject === 'head') {
function replaceBuiltins(text,filename){
const used = new Set();
let uid = 0;
//current file identificator
const fid = hasha(filename,{algorithm: 'md5'});
//remve all examples by file id
ExamplesStore.delete(new RegExp(`Ex_\\d+_${fid}`));
// parse blocks in the file
getBlocks(text).forEach(block => {
if(block.type === 'example') {
used.add('Example');
let name = `Ex_${uid++}_${fid}`;
text = text.replace(
block.fragment,
example_replacer(block.content,block.params,name)
)
css: componentStyles => {
let styles = globalStyles.replace( '__components__', componentStyles );
try {
fs.mkdirSync( 'client/dist' );
} catch ( err ) {
// noop
}
if ( dev ) {
fs.writeFileSync( `client/dist/main.css`, styles );
} else {
styles = new CleanCSS().minify( styles ).styles;
const hash = hasha( styles, { algorithm: 'md5' });
fs.writeFileSync( `client/dist/main.${hash}.css`, styles );
fs.writeFileSync( `server/manifests/css.json`, JSON.stringify({ 'main.css': `client/dist/main.${hash}.css` }) );
}
}
}),
export default function randomFolder(pathname, title) {
return path.join('src/__tests__',
pathname,
hasha(title, { algorithm: 'md5' })
);
}
async function saveResponseData(key, url, response) {
const origin = (new URL(url).origin);
let originDir = State.Cache.get(origin);
if ( ! originDir ) {
originDir = path.resolve(library_path(), origin.replace(TBL, '_'));
try {
await Fs.promises.mkdir(originDir, {recursive:true});
} catch(e) {
console.warn(`Issue with origin directory ${path.dirname(responsePath)}`, e);
}
State.Cache.set(origin, originDir);
}
const fileName = `${await hasha(key, HASH_OPTS)}.json`;
const responsePath = path.resolve(originDir, fileName);
await Fs.promises.writeFile(responsePath, JSON.stringify(response));
return responsePath;
}
const hashes = pairs.map(item =>
hasha(item.content, {
algorithm: 'md5',
})
);
constructor(name: string, actions) {
this._key = `__${hasha(name, { algorithm: 'sha256' })}__`;
this._name = name;
this._actions = actions;
}
const doLogin = async (username, password) => {
if (typeof user === 'undefined' || !user.hasOwnProperty('hash')) {
let userData = {
username: username,
hash: hasha(username, {
algorithm: 'md5'
})
}
settings.set('currentUser', userData)
user = settings.get('currentUser')
}
let session = await createSession(user, password)
return session
}
constructor(name) {
this.name = name
this.id = hasha(name, { algorithm: 'md5' })
this.ref = `${REF_PREFIX}_${this.id}`
this.trace = null
}