Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open tab when running next dev #8

Merged
merged 5 commits into from
Oct 17, 2016
Merged

Open tab when running next dev #8

merged 5 commits into from
Oct 17, 2016

Conversation

impronunciable
Copy link
Contributor

No description provided.

const open = url => {
const openers = { darwin: 'open', win32: 'start' }
const cmdName = openers[process.platform] || 'xdg-open'
exec(`${cmdName} ${url}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's probably a node module for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said this looks short and sweet :P

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one that does this and some checking, but for our use case we don't need the extra stuff https://github.com/domenic/opener/blob/master/opener.js

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a pretty small module though. Ok with me

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rauchg
Copy link
Member

rauchg commented Oct 16, 2016

An ENV to avoid this behavior might be cool?

@impronunciable
Copy link
Contributor Author

impronunciable commented Oct 16, 2016

@rauchg webpack-dev-server uses --open we can have --no-open ? That'd be webpack's convention for when the default is false

const dir = resolve(argv._[0] || '.')

build(dir)
.then(async () => {
const srv = new Server({ dir, dev: true })
await srv.start(argv.port)
console.log('> Ready on http://localhost:%d', argv.port);
open(`http://localhost:${argv.port}`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an env var is more appropriate because it's a user preference, not a project preference. It's not something you would add to the scripts commands, for example.

NEXT_OPEN_BROWSER=0 to disable it would be cool. We can check for lose equality of '0' or 'false'

if (await exists(join(dir, '..', 'pages'))) {
console.warn('> No `pages` directory found. Did you mean to run `next` in the parent (`../`) directory?')
} else {
console.warn('> Couldn\'t find a `pages` directory. Please create one under the project root')
}
}

if (['false', '0'].indexOf(process.env.NEXT_OPEN_BROWSER) === -1) {
Copy link
Member

@rauchg rauchg Oct 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/^(false|0)$/i.test() is probably better if you're aiming for succinctness and also handles FALSE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also handles FaLsE :P. I'll make the change

if (await exists(join(dir, '..', 'pages'))) {
console.warn('> No `pages` directory found. Did you mean to run `next` in the parent (`../`) directory?')
} else {
console.warn('> Couldn\'t find a `pages` directory. Please create one under the project root')
}
}

if (/^(false|0)$/i.test(process.env.NEXT_OPEN_BROWSER)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing leading !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ups, my fault

@rauchg rauchg merged commit 142a6e3 into master Oct 17, 2016
@rauchg rauchg deleted the add/open-tab branch October 17, 2016 01:49
@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 2019
ijjk pushed a commit to ijjk/next.js that referenced this pull request Apr 13, 2019
* add base of api docs and some pages

* add pages

* improve style

* list all apis

* add api pages

* scroll into view

* fix for mobile

* remove query-string

* use the same navbar with /docs, improve the scrollIntoView behavior

* animation

* fix bg color of CodeMirror gutters

* update prettier

* hide editor on mobile

* fix code color

* fix endpoints

* fix typos

* Link from delete deployment to list them

* fix overflowing width on firefox

* Fix delete dns record url

* fix ::selection color on black background

* fix key warning

* api: a single long page

* remove unused files

* Add examples requests

* Comment wrong information

* Get test token from each endopint props

* fix width

* handle hash urls

* improve handling hash url

* Remove test token

* Fix base url

* Change intro to don't specify Node deployments

* Add internal link

* Fix request body for adding a record

* Add /domains/status /domains/price and /domains/buy endpoints

* improve hash handling

* api: adjust style

* withAPI

* optimize

* set dayBanner

* fix escape on example

* Add new v2 endpoints

* adjust hash change position

* add oauth2 section

* deprecated

* fix style of deprecated

* Add more content to docs

* fix the deprecated endpoint

* Add more info for v2 endpoints

* Change section titles and, remove FAQ and add Types

* Remove table margin-left

* Use generic table component

* Remove empty blank spaces

* Improve OAuth2 docs

* update url hash using IntersectionObserver API

* Add note about logs and code under OSS fix vercel#7

* Add immutable HOC should fix #4

* Add TypeCell and BoldCell composed components

* Create section for old API endpoints

* Use new Cell components and remove deprecated endpoint

* Fix typo

* Add generic errors section

* Remove generic error codes from API basics and link to specific section

* Add more info for deployments endpoints

* Create new specific table for input, output and headers

* Use HeadersTable

* Use specific tables instead of the generic one

* Add type ID

* Add Date type

* Use Id and Date types

* Correct rate_limited error message

* Add input/output information for domains endpoints

* Add aliases input/output information

* Add secrets input/output information

* Fix prop name

* Add certificates input/output information

* Add h4 headers before tables

* Fix inconsistency of type name

* Improve ID description

* Remove row in rate limits section

* Solve typo (fix vercel#9)

* Don't run `scrollIntoViewIfNeeded` in Firefox (fix vercel#8)

* Remove unused link in navbar

* Revert c014ce2

* Add note to create secret about the max length

* Add line after each section

* Add dash before each sub link in navbar

* Add border left to selected navbar item

* Single line titles

* Example text in gray

* Only select one item in the navbar and dash in gray

* Reduce section title

* Bring button from zeit/front

* Editor + CORS Preview

* Change disabled styles

* Remove padding right in navbar

* collapse subsections when not active

* fix wrong use of styled-jsx

* Add more documentation about errors

* fix scrollIntoViewIfNeeded issue of sidebar on FireFox

* optimize rendering performance on sidebar

* adjust padding of sidebar items

* highlight shell syntax code block

* fix navbar style on /docs

* optimize section props

* fix border color

* fix NOTE text color

* Add domain errors

* replace 'immutable' with 'pure' if props are used

* immutable -> immutable-component

* fix header for displaying login state

* replace with real token on #introduction

* fix prop type

* fix NOTE on dark bg

* add shadow to editor

* fix 'Introduction' style for mobile

* fix introduction style

* fix editor border

* add spaces to notes and table headings

* adjust space between sections

* polyfill IntersectionObserver

* apply intersection-observer polyfill only on client

* apply new design for table

* fix changelog

* fix preview on mobile

* fix changelog

* fix

* remove subsections of deployment errors from navbar

* fix navbar style

* make navbar sticky on mobile

* fix hash urls

* fix navbar of /docs on mobile

* fix table for mobile

* fix navbar style on /docs on mobile

* make description of input/output tables full width on mobile

* fix definition column width on mobile

* Add more errors

* Change navbar content related to errors

* Update yarn.lock

* add file tree to demo

* handle JSON parse error

* preserve previous preview content

* add lineWrapping

* update yarn.lock

* update index.js content

* Add more errors

* Add even more domain errors

* Fix errors starting message

* Single line JSON

* fix heading level

* fix navbar padding

* log deployment demo errors

* Split DNS endpoints to another category

* Split DNS errors to another category from domain errors

* Remove placeholders

* Add new file upload endpoint documentation

* update package-lock.json

* add /v2 prefix to endpoint urls

* make the api demo work

* improve instant deployment api doc

* Fix new deployment endpoint docs

* Add teams endpoints

* Add deployment instances endpoint

* Add set scale config endpoint

* Use new Endpoint component everywhere

* Use Request component for every CURL req

* Simplify HTTP request creation

* Remove duplicated code

* Add authentiation endpoints documentation

* Document how to get deployment logs

* bump react

* remove content-type header from demo

* align demo vertically on api

* Add toggle between Docs and API Reference

* Add toggle between Docs and API Reference

* Minor fixes

* Improve toggle layout

* Fix content alignment

* Fix content alignment

* Fix typo

* Add docs/api page toggle

* Prefetch docs/api pages

* Allow active styling for toggle with a sub-page of docs/api

* Add missing required field while creating the deployment

* Improve mobile experience
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants