9 examples of 'yup npm' in JavaScript

Every line of 'yup npm' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
79function setupNpm(options: {
80 latestRuntimeGradleVersion?: string,
81 latestRuntimeGradleAndroidVersion?: string,
82 projectRuntimeGradleVersion?: string,
83 projectRuntimeGradleAndroidVersion?: string,
84 addProjectRuntime?: boolean
85}): any {
86 return {
87 getRegistryPackageData: async (packageName: string): Promise<any> => {
88 const result: any = [];
89 result["dist-tags"] = { latest: '4.1.2' };
90 result.versions = [];
91 result.versions['1.0.0'] = {
92 "name": packageName,
93 "gradle": {
94 "version": options.projectRuntimeGradleVersion,
95 "android": options.projectRuntimeGradleAndroidVersion
96 }
97 };
98 result.versions['4.1.2'] = {
99 "name": packageName,
100 "gradle": {
101 "version": options.latestRuntimeGradleVersion,
102 "android": options.latestRuntimeGradleAndroidVersion
103 }
104 };
105
106 return result;
107 }
108 };
109}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

50function _npm_package()
51{
52 console.log('Preparing package.json...');
53
54 const package_path = path.resolve(dist_path, 'package.json');
55 const package_json = JSON.parse(fs.readFileSync(path.resolve(module_path, 'package.json')).toString());
56 delete package_json.private;
57 const keep_scripts = ['install', 'build'];
58 const scripts = {};
59 for(const script of keep_scripts)
60 scripts[script] = package_json.scripts[script];
61 package_json.scripts = scripts;
62 delete package_json.devDependencies;
63 fs.writeFileSync(package_path, JSON.stringify(package_json, null, 4));
64
65 console.log('Prepared!');
66}
45async function npm(command,dir){
46 if(dir)
47 await exec(`npm --prefix ${dir} ${command}`);
48 else
49 await exec(`npm ${command}`);
50}
28export function fromNpm(command: string) {
29 return baseDir(`./node_modules/.bin/${command}`);
30}
34checkNpm() {
35 try {
36 return require("npm");
37 } catch (e) {
38 return false;
39 }
40}
77function npmUpdate(dependencies) {
78 return new Promise(function (resolve, reject) {
79 npm.commands.update(dependencies || [], function () {
80 resolve();
81 });
82 });
83}
9export function installNPMDependencies(ctx: BuildContext) {
10 return new Promise((resolve, reject) => {
11 exec(`npm install`, {
12 cwd: ctx.projectFolder,
13 }, (error, stdout) => {
14
15 if (error === null) {
16 resolve();
17 } else {
18 reject(Error(stdout));
19 }
20 });
21 });
22}
105async function npmDeps(location) {
106 let pkgInfo = await fs.readFile(path.resolve(location, 'package.json'));
107 pkgInfo = parseJson(pkgInfo);
108 return pkgInfo.dependencies;
109}
13async function addDependencies(npmOptions) {
14 const [
15 storybookVersion,
16 notesVersion,
17 actionsVersion,
18 linksVersion,
19 addonsVersion,
20 ] = await getVersions(
21 npmOptions,
22 '@storybook/angular',
23 '@storybook/addon-notes',
24 '@storybook/addon-actions',
25 '@storybook/addon-links',
26 '@storybook/addons'
27 );
28
29 const packageJson = getPackageJson();
30
31 packageJson.dependencies = packageJson.dependencies || {};
32 packageJson.devDependencies = packageJson.devDependencies || {};
33
34 packageJson.scripts = packageJson.scripts || {};
35 packageJson.scripts.storybook = 'start-storybook -p 6006';
36 packageJson.scripts['build-storybook'] = 'build-storybook';
37
38 writePackageJson(packageJson);
39
40 const babelDependencies = await getBabelDependencies(npmOptions, packageJson);
41
42 installDependencies(npmOptions, [
43 `@storybook/angular@${storybookVersion}`,
44 `@storybook/addon-notes@${notesVersion}`,
45 `@storybook/addon-actions@${actionsVersion}`,
46 `@storybook/addon-links@${linksVersion}`,
47 `@storybook/addons@${addonsVersion}`,
48 ...babelDependencies,
49 ]);
50}

Related snippets