Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(async resolve => {
const access_token = await getToken() // eslint-disable-line camelcase
const { name } = await getCfg()
const client = netlify.createClient({ access_token }) // eslint-disable-line camelcase
const sites = await client.sites()
const dir = join(process.cwd(), '.netlify-docs/build')
let pkg = {}
let newSite = true
try {
pkg = await readPackage()
} catch (err) {}
const siteName = name || `${pkg.name}-docs`
await execa.shell(
'cd .netlify-docs && yarn add react-scripts && yarn build'
)
sites.forEach(async site => {
readOrCreateConfig(program, function(err, config) {
config.client = netlify.createClient({
client_id: CLIENT_ID,
access_token: program.accessToken || (local && local.access_token) || config.access_token,
endpoint: API_ENDPOINT
});
config.siteId = program.siteId || (local && local.site_id);
config.path = program.path || (local && local.path);
config.env = program.env;
cb(config);
});
};
var readOrCreateConfig = function(options, cb) {
var config = readConfig();
if (config) {
cb(null, config);
} else if (options.accessToken) {
cb(null, {access_token: options.accessToken});
} else {
var client = netlify.createClient({client_id: CLIENT_ID, endpoint: API_ENDPOINT});
webauth.login({client: client}, function(err, token) {
config = {access_token: token.access_token};
writeConfig(config);
cb(null, config);
});
}
};