Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('initialize selected example ("amp")', async t => {
tmpDir = tmp.dirSync({ unsafeCleanup: true });
const cwd = tmpDir.name;
const goal = '> Success! Initialized "amp" example in';
const { stdout, stderr, code } = await execute(['init'], {
cwd,
input: '\n'
});
t.is(code, 0, formatOutput({ stdout, stderr }));
t.true(stdout.includes(goal), formatOutput({ stdout, stderr }));
t.true(verifyExampleAmp(cwd, 'amp'), formatOutput({ stdout, stderr }));
});
test.beforeEach(t => {
t.context.tempDir = tmp.dirSync({ prefix: 'electron-installer-snap-' })
process.chdir(t.context.tempDir.name)
})
export function tempProject(id: RepoRef = {
owner: "dummyOwner",
repo: "dummyRepo",
url: "",
}): LocalProject & ScriptedFlushable {
const dir = tmp.dirSync({ unsafeCleanup: true });
return new NodeFsLocalProject(id, dir.name, async () => dir.removeCallback()) as any as LocalProject & ScriptedFlushable;
}
const transform = function(file, encode, callback) {
if (file.isStream()) {
this.emit(
'error',
new gutil.PluginError(PLUGIN, 'Streams are not supported!'),
)
return callback()
}
const {cwd, module, out, port} = Object.assign({}, defaults, options)
const tmpDir = tmp.dirSync({unsafeCleanup: true})
const dir = out || tmpDir.name
elmCss(cwd, file.path, dir, module, port)
.then(() => glob(`${dir}/*.css`))
.then(files =>
Promise.all(files.map(file => fs.readFile(file))).then(allContent => {
allContent.map((contents, i) => {
this.push(
new gutil.File({
cwd: process.cwd(),
path: path.basename(files[i]),
contents,
}),
)
})
}),
defaultValue="jest"
>
<option value="jest">Jest/Puppeteer project (CI-friendly)</option>
<option value="text">test specification</option>
{ format === "jest" && }
{ format === "text" && }
<p>Please select suites to export:</p>
<div>
Check all
</div>
function springInitializrProject(sdm: SoftwareDeliveryMachine, params: SpringInitializrProjectCreationParameters): Promise {
const url = "https://start.spring.io/starter.zip";
const tmpDir = tmp.dirSync({unsafeCleanup: true});
const cwd = tmpDir.name;
const lastSlash = url.lastIndexOf("/");
const filename = url.substring(lastSlash + 1);
const zipFile = path.join(cwd, filename);
const urlParameters = getUrlParameters(params);
const packageJson = require("../../../package.json");
const headers = {
"User-Agent": "atomist/sdm-pack-spring-" + packageJson.version,
};
return downloadFileAs(url, zipFile, urlParameters, headers)
.then(() => decompress(zipFile, cwd))
.then(() => fs.unlinkSync(zipFile))
.then(() => new NodeFsLocalProject("spring-initializr-project", cwd));
}
public async checkout(url: string, id: RemoteRepoRef, creds: ProjectOperationCredentials): Promise {
logger.info("Attempting to download artifact [%s] for %j", url, id);
const tmpDir = tmp.dirSync({unsafeCleanup: true});
const cwd = tmpDir.name;
const lastSlash = url.lastIndexOf("/");
const filename = url.substring(lastSlash + 1);
const re = /([a-zA-Z0-9_]+)-(.*)/;
const match = re.exec(filename);
const name = match[1];
const version = match[2].replace(/.jar$/, "");
const outputPath = cwd + "/" + filename;
logger.info("Attempting to download url %s to %s", url, outputPath);
await downloadFileAs(creds, url, outputPath);
logger.info("Successfully download url %s to %s", url, outputPath);
return {
cwd,
filename,
name,
export async function filtered(p: LocalProject, globs: string[]): Promise {
if (!globs) {
logger.debug("Cannot filter project %j: No globs specified", p.id);
return p;
}
const tmpDir = tmp.dirSync({unsafeCleanup: true}).name;
logger.info("Filtered project %j at %d to %s", p.id, p.baseDir, tmpDir);
await Promise.all(globs.map(glob =>
doWithFiles(p, glob, async f => {
await promisify(fs.copyFile)(
p.baseDir + "/" + f.path,
tmpDir + "/" + f.path);
})));
return new NodeFsLocalProject(p.id, tmpDir);
}
createTmpDir( key ) {
this.tmpDir[ key ] = tmp.dirSync().name;
}